I've set everything up similarly to the Baby Bob the Hamster demo, if that helps at all, and in my main loop it checks the player's velocity and then tells it to run through an animation based on which direction the sprite is moving.
Code:
$0="Animate"
if(xv > 0) then(cycle right)
if(xv < 0) then(cycle left)
if(xv == 0) then(
if(was right) then(
set sprite frame(player,0)
)
else if(was left) then(
set sprite frame(player,7)
)
)
$0="Animate"
if(xv > 0) then(cycle right)
if(xv < 0) then(cycle left)
if(xv == 0) then(
if(was right) then(
set sprite frame(player,0)
)
else if(was left) then(
set sprite frame(player,7)
)
)
And the scripts "cycle right" and "cycle left" are defined later in the file.
Code:
script, cycle right, begin
set sprite frame(player,1)
if(xv == 0 || xv < 0) then(
was right := true
was left := false
exit script)
wait(2)
set sprite frame(player,2)
if(xv == 0 || xv < 0) then(
was right := true
exit script)
wait(2)
set sprite frame(player,3)
if(xv == 0 || xv < 0) then(
was right := true
exit script)
wait(2)
set sprite frame(player,2)
if(xv == 0 || xv <0> 0) then(
was left := true
was right := false
exit script)
wait(2)
script, cycle left, begin
set sprite frame(player,6)
if(xv == 0 || xv > 0) then(
was left := true
was right := false
exit script)
wait(2)
set sprite frame(player,5)
if(xv == 0 || xv < 0) then(
was left := true
exit script)
wait(2)
set sprite frame(player,4)
if(xv == 0 || xv < 0) then(
was left := true
exit script)
wait(2)
set sprite frame(player,5)
if(xv == 0 || xv < 0) then(
was left := true
exit script)
wait(2)
end
script, cycle right, begin
set sprite frame(player,1)
if(xv == 0 || xv < 0) then(
was right := true
was left := false
exit script)
wait(2)
set sprite frame(player,2)
if(xv == 0 || xv < 0) then(
was right := true
exit script)
wait(2)
set sprite frame(player,3)
if(xv == 0 || xv < 0) then(
was right := true
exit script)
wait(2)
set sprite frame(player,2)
if(xv == 0 || xv <0> 0) then(
was left := true
was right := false
exit script)
wait(2)
script, cycle left, begin
set sprite frame(player,6)
if(xv == 0 || xv > 0) then(
was left := true
was right := false
exit script)
wait(2)
set sprite frame(player,5)
if(xv == 0 || xv < 0) then(
was left := true
exit script)
wait(2)
set sprite frame(player,4)
if(xv == 0 || xv < 0) then(
was left := true
exit script)
wait(2)
set sprite frame(player,5)
if(xv == 0 || xv < 0) then(
was left := true
exit script)
wait(2)
end
Right now, it only changes the sprite frame when the velocity is 0, so the sprite changes left and right, but never shows any of the other frames. I don't know if I'm putting things in the wrong places or if I'm just doing something completely wrong but if anyone has any ideas I'd love some insight.[/img]
My pronouns are they/them
Ps. I love my wife



