FANDOM


There may come a time when a user may need to assign an arbitrary number of sprites a unique identifier. For instance, say the user has ten bullet sprites with a local variable. Rather than individually assigning each of them a number in a set () to () block, it might be handy to do this automatically. That way, a script could specifically call bullet number seven without hard-coding it.

First, create a global (spriteCount) variable. Then, on the stage add this code:

When flag clicked:
  set spriteCount to 0
  broadcast [count sprites] and wait
  //do something afterwards

Now, for all the sprites you want to count (and generally these will be clones of the same sprite) add this script:

When I receive [count sprites]:
  change spriteCount by 1
  set myNumber to spriteCount
  //Swap these to start the count at 0 instead of 1

Then, when the flag is clicked, each sprite will get a unique number in (myNumber).

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.