Quote: "You can add animation frames to a sprite manually using LoadSubImage and AddSpriteAnimationFrame."
I added animation frames to a sprite with AddSpriteAnimationFrame but Problem is I can't change animation when Press Left or Right Key.
Main.agc:
#include "player.agc"
SetDisplayAspect( -1 )
global Player as Integer
global MaxBullet = 10
global dim PlayerBullet[MaxBullet]
global BulletNumber = 0
global ImageName as String
global dim IdleImage[16]
global dim MoveLeftImage[16]
global dim MoveRightImage[16]
global state = 0
Game()
Function Game()
CreatePlayer()
//CreateIdle()
do
//Control Player To left and Right
if GetSpriteExists(Player) = 1
if GetRawKeyState(39) = 1 and GetSpriteX(Player) < 80
SetSpritePosition(Player,GetSpriteX(Player) + 0.7,GetSpriteY(Player))
else
if GetRawKeyState(37) = 1 and GetSpriteX(Player) > -5
SetSpritePosition(Player,GetSpriteX(Player) - 0.7,GetSpriteY(Player))
if state = 0 then state = 1
endif
endif
endif
//Control Player Animation
if state = 1
state = 2
//DeleteIdle()
CreateMoveLeft()
endif
sync()
loop
EndFunction
Player.agc
//==================>>>>>>>>>>>>>>>>>>>>> Create and Delete Idle Animation
Function CreateIdle()
SetFolder("\media\images\player\idle")
for num = 0 to 15
ImageName = "frame-" + str(num) + ".png"
IdleImage[num] = LoadImage(ImageName)
AddSpriteAnimationFrame (Player,IdleImage[num])
next num
PlaySprite(Player,10,1,0,15)
EndFunction
//Delete
Function DeleteIdle()
for x = 0 to 15
DeleteImage(IdleImage[x])
next x
EndFunction
//=========================================>>>>END
//==================>>>>>>>>>>>>>>>>>>>>> Create and Delete Move Left Animation
Function CreateMoveLeft()
SetFolder("\media\images\player\move-left")
for num = 0 to 15
ImageName = "frame-" + str(num) + ".png"
MoveLeftImage[num] = LoadImage(ImageName)
AddSpriteAnimationFrame (Player,MoveLeftImage[num])
next num
PlaySprite(Player,10,1,0,15)
EndFunction
//Delete
Function DeleteMoveLeft()
for x = 0 to 15
DeleteImage(MoveLeftImage[x])
next x
EndFunction
//=========================================>>>>END
//==================>>>>>>>>>>>>>>>>>>>>> Create and Delete Move Right Animation
Function CreateMoveRight()
SetFolder("\media\images\player\move-right")
for num = 0 to 15
ImageName = "frame-" + str(num) + ".png"
MoveRightImage[num] = LoadImage(ImageName)
AddSpriteAnimationFrame (Player,MoveRightImage[num])
next num
PlaySprite(Player,10,1,0,15)
EndFunction
//Delete
Function DeleteMoveRight()
for x = 0 to 15
DeleteImage(MoveRightImage[x])
next x
EndFunction
//=========================================>>>>END
//Create Player
Function CreatePlayer()
Player = CreateSprite(0)
SetSpriteSize(Player,25,-1)
SetSpritePositionByOffset(Player,50,85)
SetFolder("\media\images\player\idle")
for num = 0 to 15
ImageName = "frame-" + str(num) + ".png"
IdleImage[num] = LoadImage(ImageName)
AddSpriteAnimationFrame (Player,IdleImage[num])
next num
PlaySprite(Player,10,1,0,15)
EndFunction
Quote: "You need a subimages text file for the spritesheet though."
yes, but maybe other engines don't support text file. I want find a Problem for it that can use in anywhere.
Quote: "EDIT: What software are you using to create this image?"
My software are:
1- AppGameKit ImageJoiner
2- TexturePacker
3- Sprite Sheet Packer