Here is how I have my platformer movement setup / animation on my character. Note: It is only the walking animation.
//Make a player
Character = CreateSprite(14)
SetSpriteSize(Character, 100, 100)
SetSpritePosition(Character, 100, 500)
SetSpritePhysicsOn(Character, 2)
SetSpritePhysicsCanRotate(Character, 0)
SetSpriteShape (Character, 3)
//Load Character Run Animation Frames
AddSpriteAnimationFrame ( Character, LoadImage ( "skeleton-run1_0.png" ) )
AddSpriteAnimationFrame ( Character, LoadImage ( "skeleton-run1_1.png" ) )
AddSpriteAnimationFrame ( Character, LoadImage ( "skeleton-run1_2.png" ) )
AddSpriteAnimationFrame ( Character, LoadImage ( "skeleton-run1_3.png" ) )
AddSpriteAnimationFrame ( Character, LoadImage ( "skeleton-run1_4.png" ) )
AddSpriteAnimationFrame ( Character, LoadImage ( "skeleton-run1_5.png" ) )
AddSpriteAnimationFrame ( Character, LoadImage ( "skeleton-run1_6.png" ) )
/////////////////////////////////////////////////////////////////
//////Load Movement buttons////////////
If DeviceType$ = "android"
LeftButton = CreateSprite(36)
SetSpriteSize(LeftButton,125,125)
SetSpritePosition (LeftButton,100,650)
SetSpriteFlip(LeftButton,1,0)
RightButton = CreateSprite(36)
SetSpriteSize (RightButton,125,125)
SetSPritePosition (RightButton,210,650)
FixSpriteToScreen(LeftButton,2)
FixSpriteToScreen(RightButton,1)
AddVirtualButton(9,900,713,125)
SetVirtualButtonImageUp (9,40)
SetVirtualButtonImageDown(9,40)
SetVirtualButtonAlpha(9,255)
endif
//Set Character offset to screen
SetViewOffset ( GetSpriteX ( Character ) -400, 0)
//Check to see if Character can jump
RCDown = PhysicsRayCastGroup(1, GetSpriteXByOffset(Character), GetSpriteYByOffset(Character), GetSpriteXByOffset(Character), GetSpriteYByOffset(Character) + 60)
///////////////////Move Player Right left and stop/////////////////////////////////////////////////////////////////////////
if GetRawKeyState(39) = 1 // Right
SetSpritePhysicsVelocity(Character, 400, GetSpritePhysicsVelocityY(Character))
elseif GetRawKeyState(37) = 1 // Left
SetSpritePhysicsVelocity(Character, -400, GetSpritePhysicsVelocityY(Character))
else
SetSpritePhysicsVelocity(Character, 0, GetSpritePhysicsVelocityY(Character))
endif
if GetRawKeyPressed(32) = 1 AND RCDown = 1
SetSpritePhysicsVelocity(Character, GetSpritePhysicsVelocityX(Character), -950)
endif
//////////////////////////////////////////////////////////////////////////////////////////////////////
If DeviceType$ = "android"
PointerX# = GetPointerX()
PointerY# = GetPointerY()
If PointerX# > 75 and pointerY# >625 and PointerX# <250 and PointerY# < 800 and GetPointerState()=1
SetSpritePhysicsVelocity(Character, -400, GetSpritePhysicsVelocityY(Character))
PlayAnimation = 1
SetSpriteFlip(Character,1,0)
elseif PointerX# >210 and PointerY# >625 and PointerX# < 360 and PointerY# < 800 and GetPointerState()=1
SetSpritePhysicsVelocity(Character, 400, GetSpritePhysicsVelocityY(Character))
PlayAnimation = 1
SetSpriteFlip (Character,0,0)
else
PlayAnimation = 0
endif
if GetVirtualButtonPressed(9) and RCDown = 1
SetSpritePhysicsVelocity(Character, GetSpritePhysicsVelocityX(Character), -825)
endif
endif
///////////Play Sprite Animation and flip sprite depending on direction///////////////
if getrawkeystate (39) or GetRawKeyState(37) or PlayAnimation = 1
If GetRawKeyState (37) = 1
SetSpriteFlip(Character,1,0)
ElseIf GetRawKeyState(39)
SetSpriteFlip(Character,0,0)
endif
if GetSpritePlaying(Character) = 0
playsprite (Character)
endif
else
if GetSpritePlaying(Character) = 1
StopSprite(Character)
SetSpriteFrame(Character, 1)
endif
endif
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
Beta Test Age of Knights:https://play.google.com/apps/testing/com.CrazyProgrammerProductions.my_AgeOfKnights
Download JellyFish Dive:https://play.google.com/store/apps/details?id=com.CrazyProgrammerProductions.my_JellyFishSwim