I think I understand what you mean... This should give you some help. Essentially, you need to know which frames (of which image if separate Images are loaded in for some anim sequences) are the starting points for the Animations, and how many frames per animation (Naturally, this can be made a lot simpler,. if you use the same number of frames per animation sequence but it's not necessary)
Const TOTAL_FRAMES=11
Const WALK_LEFT_FRAMES=5
Const WALK_RIGHT_FRAMES=5
Const JUMP_FRAMES=5
Const IDLE_FRAMES=1
Const WALK_LEFT_START=1
Const WALK_RIGHT_START=6
Const IDLE_START=0
Const FRAME_WIDTH=32
Const FRAME_HEIGHT=32
Graphics 800,600,32,2
SetBuffer(BackBuffer())
Global AnimImage=LoadAnimImage(CurrentDir()+"MyAnimImage.bmp",FRAME_WIDTH,FRAME_HEIGHT,0,TOTAL_FRAMES)
Global THIS_ANIM_FRAMES
Global THIS_ANIM_START
Global ANIM_TIME
While Not KeyDown(1)
AnimTimer=(MilliSecs()-ANIM_TIME)*0.002
AnimTimer=AnimTimer Mod THIS_ANIM_FRAMES
Cls
DrawImage AnimImage,0,0,THIS_ANIM_START+AnimTimer
Flip
Wend
Function Movement()
Local MoveMent=KeyDown(KEY_RIGHT)-KeyDown(KEY_LEFT)
Local OldAnim=THIS_ANIM_START
THIS_ANIM_FRAMES=((Movement=0)*IDLE_FRAMES)+(WALK_LEFT_FRAMES*(Movement<0))+(WALK_RIGHT_FRAMES*(Movement>0))
THIS_ANIM_START=((Movement=0)*IDLE_START)+(WALK_LEFT_START*(Movement<0))+(WALK_RIGHT_START*(Movement>0))
If (THIS_ANIM_START<>OldAnim)
ANIM_TIME=MilliSecs()
End If
End Function
|