Mar 29, 2024 13:16:09
Help with automated changing in the y axis with clones.
view on scratch
view on legacy ocular
MrKingofScratch
loading
Clones also react to broadcasts! So, the following codeā¦
will actually increase the score twice!
To fix this, we can use a variable set to for this sprite only to keep track of what is a clone, and what is the original sprite. In the following code, the is clone? variable is set to for this sprite only.
when green flag clicked
set [score v] to [0]
create clone of [myself v]
broadcast [increase score v]
when I receive [increase score v]
change [score v] by (1)
will actually increase the score twice!
To fix this, we can use a variable set to for this sprite only to keep track of what is a clone, and what is the original sprite. In the following code, the is clone? variable is set to for this sprite only.
when green flag clickedI hope this helped!
set [score v] to [0]
set [is clone? v] to [1]
create clone of [myself v]
set [is clone? v] to [0]
broadcast [increase score v]
when I receive [increase score v]
if <(is clone?) = [0]> then
change [score v] by (1)
end