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:17:55

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

Walking animation

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 11:58:22

Daroach1
Scratcher
Registered: 2011-09-11
Posts: 1000+

Re: Walking animation

when gf clicked
forever if <not <key [left arrow v] pressed?> >
switch to costume [costume 1 v]
end

Last edited by Daroach1 (2012-08-27 11:59:44)


http://i47.tinypic.com/v83mhl.png

Offline

 

#3 2012-08-27 12:59:23

LiFaytheGoblin
Scratcher
Registered: 2011-11-14
Posts: 1000+

Re: Walking animation

hello and welcome!
Please post questions like this in the Help with Scripts Forum!

Offline

 

#4 2012-08-27 13:15:27

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: Walking animation

There are a variety of ways to do this, but one of the best ways is to have a single costume (or set of costumes if you want a walk cycle) for both directions. Scratch has a button in the sprite control pane that makes a sprite only face left or right.

http://wiki.scratch.mit.edu/images/Spritepaneheader.png
^ You want to select the button that looks like this: <-->

With this, you can make a script that rotates the sprite and moves it. It'll look something like this:

when gf clicked
forever
  if <(right arrow v) pressed>
    switch to costume [moving v]
    point in direction [90]
    move [whatever] steps
  else
    if <(left arrow v) pressed>
      switch to costume [moving v]
      point in direction [-90]
      move [whatever] steps
    else
      switch to costume [stopped v]
    end
  end
end
Does that help?


http://www.blocks.scratchr.org/API.php?action=random&amp;return=image&amp;link1=http://i.imgur.com/OZn2RD3.png&amp;link2=http://i.imgur.com/duzaGTB.png&amp;link3=http://i.imgur.com/CrDGvvZ.png&amp;link4=http://i.imgur.com/POEpQyZ.png&amp;link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

Board footer