Discuss Scratch

sky-fly
New Scratcher
2 posts

leg movement

In scratch I can make a sprite move but I can't get the legs to move! My sprite just glides!
can someone help me!!!!!!
mwiedmann
Scratcher
100+ posts

leg movement


Sprites won't animate themselves. If you want a sprite to animate like it is walking or something, you have to draw multiple costumes for it and then use the “next costume” block in your code.

The standard Cat sprite has 2 frames that you can experiment with:

When GF Clicked
forever
move 2
next costume
wait .2

This will make it look like he is walking across the screen.
drmcw
Scratcher
1000+ posts

leg movement

You need to change the costume. If you use the scratch cat then it should have two costumes that look like the legs are moving when you put a next costume inside a forever block. You'll also need to add a wait statement to slow things down, unless you're going for the roadrunner look! If you then add a move statement to the next costume then the sprite should move and look like the legs are moving too.
mwiedmann
Scratcher
100+ posts

leg movement


Here is an example that uses a timer to decide when to change the costume. It gives you a smoother animation. It also has the Cat holding some different weapons, so it demos a few different things.

Timer based animation
AwesomeMarioBros
Scratcher
97 posts

leg movement

sky-fly wrote:

In scratch I can make a sprite move but I can't get the legs to move! My sprite just glides!
can someone help me!!!!!!
That's gonna be hard, but first draw the leg movements, and then follow this script.
whenclicked
forever
nextcostumewait?secsAddhowmanysecondsyouwant!:P
Locomule
Scratcher
1000+ posts

leg movement

Instead of a timer, I use a variable that counts up by 1 but only when the sprite moves. Once it gets above a certain number, the sprite switches to the next costume and the variable resets to 1. The benefit of this technique is that your costume changes according to how much the sprite moves, which can be more realistic than using a timer. Really it depends on how complex your game is.
Adjusting the amount the variable resets at will speed up or slow down how fast the sprite appears to walk.

Last edited by Locomule (Nov. 27, 2014 23:34:26)

Locomule
Scratcher
1000+ posts

leg movement

Your post reminded me of an old project I made but never shared till now. This may or may not seem a little advanced but the theory is great to know for anyone drawing their sprites, something I highly recommend when feasible.

Coincidentally, I used wait blocks here to make the costumes change at the correct speed. Since there is nothing else going on in this project, that works fine. But in a big, complex game which will have varying amounts of things happening at any given moment the player is walking around, I'd go with the method I mentioned in my previous post.

Last edited by Locomule (Nov. 27, 2014 23:32:06)

danielperez
Scratcher
22 posts

leg movement

Well first you have to animate your sprite, so you will have costumes to replace.
Then go to the scripts and try using that code:

whenclickedforevernextcostumewait0.2secs
Kitsune-chan543
Scratcher
3 posts

leg movement

But what if you have multiple costumes for one sprite? Like, ones that aren't for walking, like equipping an item. Also, my sprite won't turn around when i tell it to turn 90 degrees left instead of right.
IronBit_Studios
Scratcher
1000+ posts

leg movement

Kitsune-chan543 wrote:

But what if you have multiple costumes for one sprite? Like, ones that aren't for walking, like equipping an item. Also, my sprite won't turn around when i tell it to turn 90 degrees left instead of right.
Please don't necropost. I suggest using the
switchcostumeto
block.
Abdullah992015
Scratcher
1 post

leg movement

Here is one way! Possibly the Best Way Ever!
whenrightkeypressedforeverrepeatuntilnotkeyrightpressed?switchcostumeto Walking form 1move5stepswait.1secsmove5stepsswitchcostumeto Walking form 2move5stepswait.1secsmove5stepsswitchcostumeto Walking form 3move5stepswait.1secsmove5stepsswitchcostumeto Walking form 4move5stepswait.1secsmove5steps

Last edited by Abdullah992015 (Aug. 13, 2015 07:38:20)

joshuaho
Scratcher
1000+ posts

leg movement

*Ahem* Hey folks, its great that you want to help out! However, this topic is rather old and I don't think the topic owner is watching it anymore. Please check the date of the posts before posting and don't bump up old threads that have been resolved. Thanks!

Powered by DjangoBB