This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2012-08-27 10:29:02

Alex7007
New Scratcher
Registered: 2012-08-27
Posts: 2

Walking Animation Help

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   smile

Offline

 

#2 2012-08-27 15:35:34

OverPowered
Scratcher
Registered: 2012-07-27
Posts: 100+

Re: Walking Animation Help

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
end
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.
Hope this is what you needed.  smile


Newest project: Tunnel TEST ~http://blocks.scratchr.org/API.php?user=OverPowered&amp;action=onlineStatus~ On my mind: Unicameralism

Offline

 

#3 2012-08-27 20:02:00

tree-hugger
Scratcher
Registered: 2011-11-19
Posts: 38

Re: Walking Animation Help

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
end
Ok 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
end
Sorry about the orange bit...
The second script is more important, the first script you can do anything you want with (so long as it still works XD).
Anyways hope I helped!  big_smile

Last edited by tree-hugger (2012-08-27 20:10:34)


http://oi48.tinypic.com/1y7tjr.jpghttp://oi50.tinypic.com/28tb34j.jpg                     http://oi50.tinypic.com/21c6v74.jpg                    ...ya, I'm weird... REAL weird...
BITBOT ALL THE WAY!!!     Only the WEIRDEST games!     (that's just  a Tree-Hugger thing)

Offline

 

#4 2012-08-28 05:58:26

jontmy00
Scratcher
Registered: 2011-11-28
Posts: 1000+

Re: Walking Animation Help

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
end
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.
Hope this is what you needed.  smile

Fixed.


FOR ALL THE NEWS ON UPDATES FOR SIMPLISTICRAFT, CLICK HERE.

Offline

 

Board footer