I'll expand upon what VanB has already said. Here's a quick example creating an animated sprite and having different 'states' so the program knows when to play an animation and when not too;
` This code was downloaded from The Game Creators
` It is reproduced here with full permission
` http://www.thegamecreators.com
rem
rem AGK Application
rem
LoadImage (1, "exp2_0.png")
CreateSprite (1, 1)
SetSpriteAnimation (1, 64, 64, 16)
SetSpriteVisible (1, 0)
exp = 0
rem A Wizard Did It!
do
If exp = 0
If GetPointerPressed() = 1
x = GetPointerX()-32
y = GetPointerY()-32
exp = 1
Endif
Endif
If exp = 1
SetSpritePosition (1, x, y)
SetSpriteVisible (1, 1)
PlaySprite (1,30)
exp = 2
Endif
If exp = 2
If GetSpriteCurrentFrame(1) = 16
SetSpriteVisible (1, 0)
SetSpriteFrame (1, 1)
exp = 0
Endif
Endif
Sync()
loop
Image needed is attached.
A character is no different, you just have more 'states' then a simple explosion. Example: idle, moveleft, moveright, jump, etc. In your program you'd just check for each state and use the playsprite() command for each.
Quick example:
If CharacterState$ = "idle"
PlaySprite( charactersprite#, fps#(speed), loop#(0/1), idleframestart#, idleframeend# )
Endif
You can do this check for each state and then play the sprite with the correct frames. This is a quick and easy approach. There's room for expansion to create smooth transitions between frames and etc.
Only other thing, get rid of that function().
It's not benefiting your program any. Now combining all the sprite creation commands into one as a function would.
Hope this makes it more clear.
Inmortalis Nox