Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Moving and Stopping Animation
- Buddems2
-
Scratcher
9 posts
Moving and Stopping Animation
I may be dumb for not knowing how to do this, but I can't figure out the code for making a character repeat its animation while holding down a key, and instantly stopping to the idle animation when not holding the key.
What the idle and walking animation looks like for more information:
What the idle and walking animation looks like for more information:
switch costume to [idlenormal v]
wait (6) secs
repeat (2)
next costume
wait (2) secs
end
switch costume to [walk1 v]
repeat (3)
wait (0.25) secs
next costume
end
wait (0.25) secs
Last edited by Buddems2 (March 23, 2024 07:10:06)
- Buddems2
-
Scratcher
9 posts
Moving and Stopping Animation
I've figured out how to construct this system. I'd show how to do it, however, it is quite lengthy.
- Infinity342
-
Scratcher
39 posts
Moving and Stopping Animation
I've got it!
I haven't tested this, let me know if you have any bugs!
when green flag clicked
forever
if <key (any v) pressed?> then
set [idle action v] to [false]
if <(walk action)=[false]> then
stop [other scripts in sprite v]
broadcast [walk action v]
set [walk action v] to [true]
end
else
set [walk action v] to [false]
if <(idle action)=[false]> then
stop [other scripts in sprite v]
broadcast [idle action v]
set [idle action v] to [true]
end
end
end
when I receive [idle action v]
switch costume to [idle normal v]
wait (6) secs
repeat (2)
next costume
wait (2) secs
end
set [idle action v] to [false]
when I receive [walk action v]
switch costume to [walk1 v]
repeat (3)
wait (0.25) secs
next costume
end
wait (0.25) secs
set [walk action v] to [false]
I haven't tested this, let me know if you have any bugs!
Last edited by Infinity342 (April 23, 2026 17:25:42)
- Discussion Forums
- » Help with Scripts
-
» Moving and Stopping Animation
