Discuss Scratch

achillescr
Scratcher
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/
RokCoder
Scratcher
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.

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
Scratcher
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.

Powered by DjangoBB