I have been trying to get the idle animation to work but i still can't seem to get it to work right. Can you please help show a small example. I'm not sure where to add in the playsprite ( 1, 35, 1, 25, 48 ).
rem load a player image
loadimage ( 1, "player_002.png" )
createsprite ( 1, 1 )
setspriteanimation ( 1, 64, 64, 16 )
setspritesize ( 1, 75, 75 )
setspriteposition ( 1, 200, 100 )
setspritedepth ( 1, 4 )
setspriteshape ( 1, 3 )
setspritephysicson ( 1, 2 )
rem move with cursor keys and joystick
mx#=GetVirtualJoystickX( 1 )
my#=GetVirtualJoystickY( 1 )
rem when there is no input stop animation
if ( mx# = 0.0 and my# = 0.0 )
stopsprite ( 1 )
setspriteframe ( 1, 9 )
else
rem find player position
x# = getspritex ( 1 )
y# = getspritey ( 1 )
rem find healthbar position
hx# = getspritex ( 5 )
hy# = getspritey ( 5 )
rem work out movement direction
x1# = x# - mx#
y1# = y# - my#
rem face the correct angle
angle# = atanfull ( x1# - x#, y1# - y# )
setspriteangle ( 1, angle# )
rem position player
setspriteposition ( 1, x# + ( mx# / .40 ), y# + ( my# / .40 ) )
rem position health bar
setspriteposition ( 5, x# + ( mx# / .40 ), y# + ( my# / .40 ) )
rem scroll the screen
SetViewOffset ( x# - 200, y# - 100 )
SetViewOffset ( hx# - 200, hy# - 100 )
rem play players animation
if getspriteplaying ( 1 ) = 0
playsprite ( 1, 11, 1, 1, 8 )
endif
endif