Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Moving Sprites using keys
- Sonic2HD
- Scratcher
16 posts
Moving Sprites using keys
I made a script with a stand sprite,run sprite,jump sprite and a block sprite. I made a script which made it move with the run sprite with right arrow key but when I did it with left key,it started to move with the stand sprite. Is this a glitch or a problem or something like that? The Scratch Team could be able to sort this. Please do so!
Last edited by Sonic2HD (Nov. 8, 2013 22:19:19)
- sonicfan12p
- Scratcher
1000+ posts
Moving Sprites using keys
I assume you mean running costume? You don't need multiple sprites for animations like that. Also, could you share and link to your project?
Comeback time? Maybe?
- Sonic2HD
- Scratcher
16 posts
Moving Sprites using keys
The link is http://scratch.mit.edu/projects/14082682/ Check it and it will move while standing
Last edited by Sonic2HD (Nov. 8, 2013 22:23:18)
- Sonic2HD
- Scratcher
16 posts
Moving Sprites using keys
Are you doing opposite? It seems it is moving while standing to me. It's meant to be running
- KermitMC
- Scratcher
100+ posts
Moving Sprites using keys
also i just noticed this only fixes the jumping sry.
use this code for the movement
use this code for the movement
when gf clickedmake this separate to your running script
forever
if (key pressed [right v])
repeat until <not (key pressed [right v])>
switch to costume [run1]
wait (0.05) secs
switch to costume [run2]
wait (0.05) secs
end
switch to costume [stand]
Last edited by KermitMC (Nov. 8, 2013 22:44:31)
- sonicfan12p
- Scratcher
1000+ posts
Moving Sprites using keys
Fixed scratchblocks. also i just noticed this only fixes the jumping sry.
use this code for the movementwhen gf clickedmake this separate to your running script
forever
if <key [right arrow v] pressed?>
repeat until <not <key [right arrow v] pressed?>>
switch to costume [run1]
wait (0.05) secs
switch to costume [run2]
wait (0.05) secs
end
switch to costume [stand]
Edit: You got it! And you can code in scratchblocks by using these tags.
[scratchblocks]
when gf clicked
say [Scratchblocks are awesome!] for [5] secs
set [Awesomeness v] to [Awesome]
[/scratchblocks]
when gf clicked
forever
say [Scratchblocks are awesome!] for [5] secs
set [Awesomeness v] to [Awesome]
end
Last edited by sonicfan12p (Nov. 8, 2013 22:52:30)
Comeback time? Maybe?
- JDY9
- Scratcher
17 posts
Moving Sprites using keys
Try this script:
when green flag clicked
forever
if <up arrow> then
point in direction (0 v)
move () steps
end
if <key [left arrow v] pressed?> then
point in direction (-90 v)
move () steps
end
if <key [right arrow v] pressed?> then
point in direction (90 v)
move () steps
end
if <key [down arrow v] pressed?> then
point in direction (180 v)
move () steps
end
end
Last edited by JDY9 (May 3, 2014 05:49:36)
- Discussion Forums
- » Help with Scripts
- » Moving Sprites using keys