Hello. I was trying to make a walking animation of my sprite of sora from kingdom hearts chain of memories, but i just cant get it to work. What i am trying to do is to have the sprite change costumes and move if i am holding down the left key, but when i let the key go i want it to go back to the first costume. If anyone has any ideas it would be much appreciated. Thanks
Offline
I believe this is what you are looking for.
when gf clicked forever switch to costume [Idle v] if <key [right arrow v] pressed> point in direction (90 v) repeat until <not <key [right arrow v] pressed>> change x by (WalkSpeed)//WalkSpeed = How fast character moves wait (WalkWait) secs //WalkWait = How long delay between costumes is next costume if <(costume #) > (LastWalkCostume)> switch to costume [Walk1 v] end end if <key [left arrow v] pressed> point in direction (-90 v) repeat until <not <key [left arrow v] pressed>> change x by ((WalkSpeed) * (-1)) wait (WalkWait) secs switch to costume ((costume #) - (1)) if <(costume #) > (LastWalkCostume)> switch to costume [Walk1 v] end endFor this to work, you need to set the sprite to only point horizontally. To do this, look to the left of the direction-testing area in the sprite area. You will see three options, select the middle one, or the two-arrowed option.
Offline
This is the simplest way I know of to do this:
Here's the normal script for moving:
when gf clicked forever if <key [left arrow v] pressed?> switch to costume [moving left 1 v] wait [0.5] secs put the "wait" in if you have any more costumes in your walking animation put the other costumes where these blocks are and put a wait in between each one end if <key [right arrow v] pressed?> switch to costume [moving right 1 v] do the same as above only with your right moving animations end endOk here's the other script you need for this (they both go in the same sprite):
when gf clicked forever if (not ((key [left arrow v]) or (key [right arrow v]))) switch to costume [idle position v] end endSorry about the orange bit...
Last edited by tree-hugger (2012-08-27 20:10:34)
Offline
OverPowered wrote:
I believe this is what you are looking for.
when gf clicked forever switch to costume [Idle v] if <key [right arrow v] pressed?> point in direction (90 v) repeat until <not <key [right arrow v] pressed?>> change x by (WalkSpeed)//WalkSpeed = How fast character moves wait (WalkWait) secs //WalkWait = How long delay between costumes is next costume if <(costume #) > (LastWalkCostume)> switch to costume [Walk1 v] end end if <key [left arrow v] pressed?> point in direction (-90 v) repeat until <not <key [left arrow v] pressed?>> change x by ((WalkSpeed) * (-1)) wait (WalkWait) secs switch to costume ((costume #) - (1)) if <(costume #) > (LastWalkCostume)> switch to costume [Walk1 v] end endFor this to work, you need to set the sprite to only point horizontally. To do this, look to the left of the direction-testing area in the sprite area. You will see three options, select the middle one, or the two-arrowed option.
Hope this is what you needed.
Fixed.
Offline