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.
For 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.whenclicked
foreverswitch to costumeIdle ▼ifkeyright arrow ▼pressedpoint in direction90 ▼repeat untilnotkeyright arrow ▼pressedchange x byWalkSpeedWalkSpeed = How fast character moveswaitWalkWaitsecsWalkWait = How long delay between costumes isnext costumeifcostume #>LastWalkCostumeswitch to costumeWalk1 ▼ifkeyleft arrow ▼pressedpoint in direction-90 ▼repeat untilnotkeyleft arrow ▼pressedchange x byWalkSpeed*-1waitWalkWaitsecsswitch to costumecostume #-1ifcostume #>LastWalkCostumeswitch to costumeWalk1 ▼
Offline
This is the simplest way I know of to do this:
Here's the normal script for moving:
Ok here's the other script you need for this (they both go in the same sprite):whenclicked
foreverifkeyleft arrow ▼pressed?switch to costumemoving left 1 ▼wait0.5secsput the "wait" in if you have any more costumes in your walking animationput the other costumes where these blocks are and put a wait in between each oneifkeyright arrow ▼pressed?switch to costumemoving right 1 ▼do the same as above only with your right moving animations
Sorry about the orange bit...whenclicked
foreverifnot ((key [left arrow v]) or (key [right arrow v]))switch to costumeidle position ▼
Last edited by tree-hugger (2012-08-27 20:10:34)
Offline
OverPowered wrote:
I believe this is what you are looking for.
For 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.whenclicked
foreverswitch to costumeIdle ▼ifkeyright arrow ▼pressed?point in direction90 ▼repeat untilnotkeyright arrow ▼pressed?change x byWalkSpeedWalkSpeed = How fast character moveswaitWalkWaitsecsWalkWait = How long delay between costumes isnext costumeifcostume #>LastWalkCostumeswitch to costumeWalk1 ▼ifkeyleft arrow ▼pressed?point in direction-90 ▼repeat untilnotkeyleft arrow ▼pressed?change x byWalkSpeed*-1waitWalkWaitsecsswitch to costumecostume #-1ifcostume #>LastWalkCostumeswitch to costumeWalk1 ▼
Hope this is what you needed.![]()
Fixed.
Offline