Discuss Scratch

PFTryhard
New Scratcher
13 posts

How to completely reset all sprites

In my game I use a reset button instead of the flag button, and whats supposed to happen is that when you die “Player” broadcasts “Stop All”, and then you have the option to replay. Because of the way I made my obstacles, they clones themselves, so when you press replay, instead of creating say, 1 clone per sec they make 2, etc. Stop all doesn't work, so is there a way to completely reset everything (there is some stuff I want to keep between deaths so not a HARD reset). Here's the game https://scratch.mit.edu/projects/367346575/
nyankatpro
Scratcher
500+ posts

How to completely reset all sprites

What I'd do is replace every “when flag clicked” block with a “when broadcast received” block, and use the broadcast in your restart code.
Paigeri
Scratcher
500+ posts

How to completely reset all sprites

PFTryhard wrote:

In my game I use a reset button instead of the flag button, and whats supposed to happen is that when you die “Player” broadcasts “Stop All”, and then you have the option to replay. Because of the way I made my obstacles, they clones themselves, so when you press replay, instead of creating say, 1 clone per sec they make 2, etc. Stop all doesn't work, so is there a way to completely reset everything (there is some stuff I want to keep between deaths so not a HARD reset). Here's the game https://scratch.mit.edu/projects/367346575/
I 100% agree with @nyankatpro - I think this is the easiest and most effective way to do this.
GemStoneExtra
Scratcher
17 posts

How to completely reset all sprites

try this: make a new variable, name it whatever you want. i will use ‘clonedel’ as an example.

first, you will go to your player sprite. before every ‘broadcast stop’, change ‘clonedel’ to 1:
setclonedelto1broadcaststop

then, do these in any sprite:
whenclickedsetclonedelto0
whenIreceivereplaysetclonedelto0

now go to each sprite that gets cloned and put this in:
whenIstartasaclonewaituntilclonedel=1deletethisclone

that should fix it! good luck!
PFTryhard
New Scratcher
13 posts

How to completely reset all sprites

nyankatpro wrote:

What I'd do is replace every “when flag clicked” block with a “when broadcast received” block, and use the broadcast in your restart code.
I tried that, doesn't work for some reason. What I'm thinking is happening is that when I die and go to the score screen the obstacles keep generating clones of themselves who then generate more clones? Idk, but yeah, I already tried the whole broadcast thing. It's probably a problem with the obstacles code if you care to go in and look for it. Thx
PFTryhard
New Scratcher
13 posts

How to completely reset all sprites

nyankatpro wrote:

What I'd do is replace every “when flag clicked” block with a “when broadcast received” block, and use the broadcast in your restart code.
I tried that, doesn't work for some reason. What I'm thinking is happening is that when I die and go to the score screen the obstacles keep generating clones of themselves who then generate more clones? Idk, but yeah, I already tried the whole broadcast thing. It's probably a problem with the obstacles code if you care to go in and look for it. Thx
nyankatpro
Scratcher
500+ posts

How to completely reset all sprites

if you have a problem with scripts continuing to run, just use a broadcast that sends out “stop other scripts in sprite” commands to every sprite.
imfh
Scratcher
1000+ posts

How to completely reset all sprites

You should run delete this clone after stop other scripts in sprite. Otherwise, it is possible that an undeleted clone will receive the Replay broadcast and start creating extra clones.

Powered by DjangoBB