How to make hero revert to "walking" sprite once k
Posted: Thu Mar 05, 2015 1:15 am
I have the following code which makes my hero "run" when I hold down the "S" key. It both changes the characters speed and their sprite changes to their "running sprite." The code is here:
This is good and all, but if I click the "S" button while stationary my hero changes to look as if they are running even though they are standing still.
To attempt to fix this I made a reset code which was called in my autorun while loop, it looked like this:
It didn't work as intended... As I see it, it's checking if I'm in motion every tick and resetting my sprite if I am not. But instead what is happening is it keeps reseting my sprite even when I am in motion. I can not understand why.
Can anyone suggest an alternate way of handling this? Or point out any mistake if I made one?
Code: Select all
plotscript, On Keypress Handler 0, begin
if(hero is walking(me) == false) then(
set hero speed(me, 4)
#Set leader to walking
If (hero by slot (0) == hero:Taras) then(
set hero picture (0, 44)
) else if (hero by slot (0) == hero:Antonina) then(
set hero picture (0, 47)
) else if (hero by slot (0) == hero:Rodion) then(
set hero picture (0, 37)
)
### S ###
if(key is pressed(key:S)) then(
set hero speed(me, 5)
#Set leader to running
If (hero by slot (0) == hero:Taras) then(
set hero picture (0, 99)
) else if (hero by slot (0) == hero:Antonina) then(
set hero picture (0, 100)
) else if (hero by slot (0) == hero:Rodion) then(
set hero picture (0, 98)
)
)
)...To attempt to fix this I made a reset code which was called in my autorun while loop, it looked like this:
Code: Select all
script, resetRun, begin
if(hero is walking(me) == false) then(
#Set leader to walking
If (hero by slot (0) == hero:Taras) then(
set hero picture (0, 44)
) else if (hero by slot (0) == hero:Antonina) then(
set hero picture (0, 47)
) else if (hero by slot (0) == hero:Rodion) then(
set hero picture (0, 37)
)
)
endCan anyone suggest an alternate way of handling this? Or point out any mistake if I made one?