Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Idle Breakout Ball cloning issue
- achillescr
-
5 posts
Idle Breakout Ball cloning issue
I am currently working on an idle breakout game for scratch and their is an odd glitch where the number of ball doubles every time you buy one!
Can anyone help with this glitch?
Game link: https://scratch.mit.edu/projects/1046585367/
Can anyone help with this glitch?
Game link: https://scratch.mit.edu/projects/1046585367/
- RokCoder
-
1000+ posts
Idle Breakout Ball cloning issue
This is the usual case of sprite and clones receiving broadcast messages. If you already have a clone and broadcast Buy Ball then both the sprite and the clone receive the message and both then create clones. Fix this by only allowing the main sprite to react to the broadcast.
Also worth noting that your score will stop flickering when in double digits if you edit Show Score and make it into a non-refresh custom block.
when flag clicked
set [_clone v] to (1) // insert this line at the top of your green flag block - _clone is a "for this sprite only" variable
when I start as a clone
set [_clone v] to (0) // insert this line at the top of your "when I start as a clone" block
when I receive [buy ball v]
if <(_clone) = (0)> then
set [Ball Type v] to [Ball]
create clone of [myself v]
end
when I receive [buy plasma ball v]
if <(_clone) = (0)> then
set [Ball Type v] to [Plasma Ball]
create clone of [myself v]
end
Also worth noting that your score will stop flickering when in double digits if you edit Show Score and make it into a non-refresh custom block.
- Jlerpy
-
1000+ posts
Idle Breakout Ball cloning issue
Another method: get the buttons to make the clones, rather than getting Sprite2 to clone itself. That way you don't need to worry about clones receiving broadcasts.
- Discussion Forums
- » Help with Scripts
-
» Idle Breakout Ball cloning issue