Discuss Scratch

mushboom
Scratcher
13 posts

Clones stop spawning after a while

Lets say I have a spaceship that shoots lasers that act like bullets whenever the spacebar is held down. it works normal until a seemingly random amount of time and then decides to just stop working. the clones stop generating completely and i have no idea why. My working theory is that every time my computer slows down it does it, but it could really be anything as that doesn't seem to be the case. (It's not a sprite limit, after they hit an edge of the screen they disappear)
CamG777
Scratcher
100+ posts

Clones stop spawning after a while

Are you using this block to detect the space bar being pressed?
when [Space v] key pressed

Last edited by CamG777 (Jan. 10, 2022 19:32:54)


Breadsticks
Apples
Cats

<[1] = [1]>
Dezach
Scratcher
100+ posts

Clones stop spawning after a while

I think it is related to the number of clones. The limit is 300. You should delete the clones when you don't need them anymore.
You should send the link to the project.

Last edited by Dezach (Jan. 10, 2022 19:33:44)

CamG777
Scratcher
100+ posts

Clones stop spawning after a while

Dezach wrote:

I think it is related to the number of clones. The limit is 300. You should delete the clones when you don't need them anymore.

That's where I was going. The clones are making more clones.

Breadsticks
Apples
Cats

<[1] = [1]>
mushboom
Scratcher
13 posts

Clones stop spawning after a while


That's where I was going. The clones are making more clones.
That's what it is! how can I delete them fast enough to prevent them from duplicating themselves?
mushboom
Scratcher
13 posts

Clones stop spawning after a while

CamG777 wrote:

Dezach wrote:

I think it is related to the number of clones. The limit is 300. You should delete the clones when you don't need them anymore.

That's where I was going. The clones are making more clones.
That's what it is! how can I delete them fast enough to prevent them from duplicating themselves?
(Sorry for typing it again just didnt work the first time)

Last edited by mushboom (Jan. 10, 2022 20:32:57)

CamG777
Scratcher
100+ posts

Clones stop spawning after a while

Try changing the laser cloning script to this:

if <key [Space v] pressed?> then
Make clones
end

and then under your bullet clone:

if <touching [Edge v] ?> then
delete this clone
end

Breadsticks
Apples
Cats

<[1] = [1]>
mushboom
Scratcher
13 posts

Clones stop spawning after a while

CamG777 wrote:

Try changing the laser cloning script to this:

if <key [Space v] pressed?> then
Make clones
end

and then under your bullet clone:

if <touching [Edge v] ?> then
delete this clone
end

I had something similar, but when the spacebar is released it stops creating clones (so i can hold it down). Do you think this is the problem? I don't know how to send code in scratch forums, but it just said

When space key pressed
forever
repeat until not key space pressed
create clone of myself
wait 0.1 seconds

and for the clone I have

when I start as clone
forever
show
repeat until y position > 188
change y by 20
(then out of the repeat)
delete this clone

do you think its the forever loops?
CamG777
Scratcher
100+ posts

Clones stop spawning after a while

For the clone try this
when I start as a clone
repeat until <(y position) > [188]>
change y by (20)
end
delete this clone

And then for the clone creation

forever
if <key [Space v] pressed?> then
create clone of [Myself v]
wait (0.1) secs
end
end

Breadsticks
Apples
Cats

<[1] = [1]>
mushboom
Scratcher
13 posts

Clones stop spawning after a while

CamG777 wrote:

For the clone try this
when I start as a clone
repeat until <(y position) > [188]>
change y by (20)
end
delete this clone

And then for the clone creation

forever
if <key [Space v] pressed?> then
create clone of [Myself v]
wait (0.1) secs
end
end
That was probably it. Thanks!

Powered by DjangoBB