Discuss Scratch

jayduhhhh
Scratcher
3 posts

how do you make a cool down when firing lasers with this script?

when green flag clicked
hide
forever
if <key [space] pressed?> then
create clone of [myself]
end

when I start as a clone
go to [spaceship]
point in direction (90)
show
repeat until <touching [edge] >
move (10) steps
delete this clone
end
Cool_Dude2022
Scratcher
100+ posts

how do you make a cool down when firing lasers with this script?

jayduhhhh wrote:

when green flag clicked
hide
forever
if <key [space] pressed?> then
create clone of [myself]
end

when I start as a clone
go to [spaceship]
point in direction (90)
show
repeat until <touching [edge] >
move (10) steps
delete this clone
end

You can use a variable to do this easily:

when green flag clicked
hide
forever
if <<key [space] pressed?> and <(Cooldown) = [F]>> then
create clone of [myself]
end

when I start as a clone
set [Cooldown v] to [T]
go to [spaceship]
point in direction (90)
show
repeat until <touching [edge] >
move (10) steps
delete this clone
set [Cooldown v] to [F]
end

Did I help you fix your problem? If so, please nominate my project to be featured!

If my code is used, credit is NOT required
MrKingofScratch
Scratcher
100+ posts

how do you make a cool down when firing lasers with this script?

the simplest solution is
forever
if <key [space v] pressed?> then
create clone of [myself v]
wait (cooldown amount here) secs
end
end
However, you can mess around with
(timer)
(set a “target” time that when reached should end the cool down, then wait until the timer is at that number)

Last edited by MrKingofScratch (March 28, 2024 17:32:28)


Last edited by kaj (Tomorrow 00:00:00)
100th post!
jayduhhhh
Scratcher
3 posts

how do you make a cool down when firing lasers with this script?

PS. in laser sprite
jayduhhhh
Scratcher
3 posts

how do you make a cool down when firing lasers with this script?

THANK YOU!
Shrek_em
Scratcher
34 posts

how do you make a cool down when firing lasers with this script?

MrKingofScratch wrote:

the simplest solution is
forever
if <key [space v] pressed?> then
create clone of [myself v]
wait (cooldown amount here) secs
end
end
However, you can mess around with
(timer)
(set a “target” time that when reached should end the cool down, then wait until the timer is at that number)
@MrKingofScratch 's solution is far easier that the other one

Shrek_em

Really bad coder

Really good ideas

Want to make a signature?
Click this purple thing to figure out how

Powered by DjangoBB