Discuss Scratch

numberonetest
New to Scratch
2 posts

Help with clone variables

WHAT IS GOING ON!!!

I dont know why my radiuses are showing when clone #1 cat is clicked. Basically, radius and towers have the local variables which changes every time a new clone appears. I need help with this PLEASE!




link to project is here
scubajerry
Scratcher
1000+ posts

Help with clone variables

The problem is that when you start the clone you are incrementing the SPRITE ONLY variable CLONE #, it always starts at 0 and then is incremented to 1. You need a global variable that gets incremented with each new clone and the CLONE # to NEW VARIABLE.

You may also may want to put in a WAIT (tenth of a second) secs between CREATE CLONE statements.

Last edited by scubajerry (Aug. 29, 2013 23:47:47)

numberonetest
New to Scratch
2 posts

Help with clone variables

thanks, no need for more help, project is OUT!!

Last edited by numberonetest (Aug. 30, 2013 00:13:17)

DadOfMrLog
Scratcher
1000+ posts

Help with clone variables

Another way to make a clone number is to have each clone create the next one. Because local variables get inherited from the clone that creates the new clone, you can avoid the need for a global variable, and also avoid the wait between creating clones.

That works fine if you create a fixed number of clones at the start of, or at a specfic point in, your project. But there may be other occasions when using a global would be more straightforward (though I'd still suggest that it's useful to try to find a way to make each clone create the following clone, so you can avoid any need for a wait between clone creation).

One other important thing you should watch out for when using clones…
All clones respond to hat blocks such as “when _ key pressed” and “when I receive _”.
This means if you only want one clone (e.g. the original sprite) to run some script when that event happend, you have to check that the clone# matches the one you want before continuing.

Hope that's useful!

Last edited by DadOfMrLog (Aug. 30, 2013 00:41:19)



Alternate account: TheLogFather –– HowTos and useful custom blocks (see studio). Examples below…


- String manipulation - - - X to power of Y - - - Clone point to clone - Detect New Scratcher - Speed tests studio -

Powered by DjangoBB