Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » how do u make a sprite animate and shoot a projectile without delay?
- melendez_n2013
-
Scratcher
6 posts
how do u make a sprite animate and shoot a projectile without delay?
how do u make a sprite animate and shoot a projectile without delay?
- melendez_n2013
-
Scratcher
6 posts
how do u make a sprite animate and shoot a projectile without delay?
when green flag clickedit has a delay
forever
next costume
wait (0.2) secs
if <key [ space ] pressed?> then
broadcast [shoot projectile ]
end
end
Last edited by melendez_n2013 (Sept. 9, 2025 21:25:54)
- The_Cool_Test_Alt
-
Scratcher
100+ posts
how do u make a sprite animate and shoot a projectile without delay?
It doesn't? Interesting. Can you show us the code under the when I receive shoot projectile block?
If it's too much to type here, you can share the project and give the link instead.
If it's too much to type here, you can share the project and give the link instead.
Last edited by The_Cool_Test_Alt (Sept. 9, 2025 21:26:02)
- melendez_n2013
-
Scratcher
6 posts
how do u make a sprite animate and shoot a projectile without delay?
when I start as a clone
forever
repeat until <touching [ edge] ?>
move (10) steps
end
Last edited by melendez_n2013 (Sept. 9, 2025 21:28:47)
- melendez_n2013
-
Scratcher
6 posts
how do u make a sprite animate and shoot a projectile without delay?
when I receive [ shootprojectile]
create clone of [ self]
- ninjacat28_
-
Scratcher
100+ posts
how do u make a sprite animate and shoot a projectile without delay?
when green flag clickedit has a delay
forever
next costume
wait (0.2) secs
if <key [ space ] pressed?> then
broadcast [shoot projectile ]
end
end
Because of the ,Wait (0.2), seconds block.
Last edited by ninjacat28_ (Sept. 9, 2025 22:14:08)
- ninjacat28_
-
Scratcher
100+ posts
how do u make a sprite animate and shoot a projectile without delay?
when I receive [ shootprojectile]
create clone of [ self]
That code wouldn't work as clones receive messages so you are telling the clones + main sprite to create a clone of themself so: 1,2,4,8,16,32,64,128,256. and we'll have reached the clone limit next shoot.
Last edited by ninjacat28_ (Sept. 9, 2025 22:16:08)
- han614698
-
Scratcher
1000+ posts
how do u make a sprite animate and shoot a projectile without delay?
I see the issue. You need to remove the “wait 0.2 seconds” block. The “key pressed” check is only happening once every 0.2 seconds. Which means, sometimes you have to hold down space for 0.2 seconds to spawn a clone:when green flag clickedit has a delay
forever
next costume
wait (0.2) secs
if <key [ space ] pressed?> then
broadcast [shoot projectile ]
end
end
when gf clicked
forever
next costume
-wait (0.2) secs
if <key [space v] pressed?> then
broadcast (shoot projectile v)
end
end
Here, I would recommend you replace this code, with this:when I start as a clone
forever
repeat until <touching [ edge] ?>
move (10) steps
end
when I start as a clone
repeat until <touching (edge v)?>
move (10) steps
end
+delete this clone
The forever loop is unnecessary - once the condition “is touching edge?” is met, the repeat until loop will be “dead”. The forever loop would not do anything.
I added the “delete this clone” block, because Scratch has a limit of 300 clones. This means, after you shot 300 projectiles, without this block, your project would stop shooting ANY projectiles, at all.
Last edited by han614698 (Sept. 10, 2025 03:13:22)
- Discussion Forums
- » Help with Scripts
-
» how do u make a sprite animate and shoot a projectile without delay?