Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Clones And Targeting
- BenAndMe
-
100+ posts
Clones And Targeting
When I click on a clone it sets a variable to 1, when this happens a menu pops-up (This is a different sprite) and there are buttons on the menu (also different sprites).
Now when you click one of the buttons on the menu I want to change a variable but only for the sprite, ik how to set each clone a different variable score, but when I click the button how do I target the clone that I clicked first to open the menu?
Now when you click one of the buttons on the menu I want to change a variable but only for the sprite, ik how to set each clone a different variable score, but when I click the button how do I target the clone that I clicked first to open the menu?
- deck26
-
1000+ posts
Clones And Targeting
Can you share your project so we can make more sense of your post. Not sure why you needed to create a new topic here though,
- BenAndMe
-
100+ posts
Clones And Targeting
https://scratch.mit.edu/projects/194159176/
Go play > Map road >Towers > Click the monkey > Place it anywhere (Click to place, only on the green) > Then click it again!
Now look at the bottom, when I click an upgrade I want it to only apply to the clone I clicked
Go play > Map road >Towers > Click the monkey > Place it anywhere (Click to place, only on the green) > Then click it again!
Now look at the bottom, when I click an upgrade I want it to only apply to the clone I clicked
- deck26
-
1000+ posts
Clones And Targeting
The answer still looks like cloneIDs and or variables to me. Give each clone a unique ID. When it is clicked (when this sprite clicked) set ‘whichclone’ to the cloneID. When an upgrade is clicked send a broadcast and the clone which was last clicked can tell it was the last one - the broadcast receiver just needs to check cloneID against ‘whichclone’.
As long as cloneID is a local variable (this sprite only) each clone has its own copy. Get the sprite to manage the creation of clones so it can increase cloneID each time a clone is created. You may need a separate local variable to identify the sprite from the clones or you could use a script that is started before the first clone is created and loops, waiting for some global variable to be set to 1 to create a clone and sets it to 0 after creating a clone.
As long as cloneID is a local variable (this sprite only) each clone has its own copy. Get the sprite to manage the creation of clones so it can increase cloneID each time a clone is created. You may need a separate local variable to identify the sprite from the clones or you could use a script that is started before the first clone is created and loops, waiting for some global variable to be set to 1 to create a clone and sets it to 0 after creating a clone.
- deck26
-
1000+ posts
Clones And Targeting
I've done all I can for tonight. I'm trying to watch something on tv with subtitles.
- Discussion Forums
- » Help with Scripts
-
» Clones And Targeting