I've been trying to work this out all day and I'm almost there, but I'm not sure why my sprite animation is playing only after I release the mouse button...
What should happen is that the ship should bank left if you click to the left of the ship and it should bank right when you click anywhere to the right of the ship. It will roll back to 0 degrees when the mouse button is released, but I've REM'd out that procedure to try to help determine the problem area
The sprite moves left and right, no problem, but the frames don't advance until the mouse button is released.
My frames in the following code are a bit off still, but my major issue is that the sprite's animation not playing until the mouse is released.
All thoughts on how to do this or do it better are quite welcome.
A side question related to this project is: the sprite sheet is larger than 1024, is the sheet being scaled down to 1024 even though I am using frames that are 256x256?
Thanks!!
LoadImage(3,"ship.png")
CreateSprite(3,3)
SetSpriteAnimation(3,256,256,40)
SetSpritePosition(3,50,70)
SetSpriteSize(3,15,-1)
movingtext = createtext("")
frametext = createtext("")
SetTextPosition(movingtext,0,0)
SetTextSize(movingtext,2)
SetTextPosition(frametext,0,5)
SetTextSize(frametext,2)
checktext = CreateText("")
SetTextPosition(checktext,0,8)
SetTextSize(checktext,2)
do
frame = GetSpriteCurrentFrame(3)
if GetRawMouseLeftState() = 1
move_ship = 1
else
move_ship = 0
endif
if move_ship = 1
pointerX# = GetPointerX()
//move ship left
if pointerX# < GetSpriteXByOffset(3)
//don't let ship move off screen
if GetSpriteX(3) > 5
SetSpriteX(3,GetSpriteX(3)-0.5)
endif
if frame = 1 or frame = 20 or frame = 40
SetTextString(checktext,"if frame 1,20,or 40")
frame_start = 1
frame_end = 10
call_play = 1
elseif frame >= 21 and frame <= 30
SetTextString(checktext,"if frame >= 21 and frame <= 30")
frame_start = 61 - frame
frame_end = 40
call_play = 1
elseif frame >= 31 and frame < 40
SetTextString(checktext,"if frame >= 31 and frame < 40")
frame_start = frame
frame_end = 40
call_play = 1
elseif frame <= 10
SetTextString(checktext,"if frame <= 10")
frame_start = frame
frame_end = 10
call_play = 1
endif
SetTextString(movingtext,"moving left")
endif
// move ship right
if pointerX# > GetSpriteXByOffset(3)
// don't let ship move off screen
if GetSpriteX(3) < 90
SetSpriteX(3,GetSpriteX(3)+0.5)
endif
if frame = 1 or frame = 20 or frame = 40
SetTextString(checktext,"if frame = 1 or frame = 20 or frame = 40")
frame_start = 21
frame_end = 30
call_play = 1
elseif frame >= 1 and frame <= 10
SetTextString(checktext,"if frame >= 1 and frame <= 10")
frame_start = 21 - frame
frame_end = 30
call_play = 1
elseif frame >= 21
SetTextString(checktext,"if frame >= 21")
frame_start = frame
frame_end = 30
call_play = 1
endif
SetTextString(movingtext,"moving right")
endif
endif
remstart
if GetRawMouseLeftReleased() = 1
if frame <= 20
frame_start = frame
frame_end = 20
elseif frame >= 21
frame_start = frame
frame_end = 40
endif
just_released = 1
endif
remend
SetTextString(frametext,"Current: "+str(frame)+" Start: "+str(frame_start)+" End: "+str(frame_end))
if call_play = 1
PlaySprite(3,20,0,frame_start,frame_end)
call_play = 0
endif
remstart
if just_released = 1
//SetTextString(checktext,"calling play sprite")
PlaySprite(3,20,0,frame_start,frame_end)
just_released = 0
moving = 0
endif
remend
sync()
loop