Cloning Sprites - basics

What's problem you are encountering?

  • Snap! is showing five balls (sprites), when only four should be shown.
  • The balls don't have stable "names." When I ask each of them to say its position in the list, they each cycle through all of the positions.
  • Can I create a name attribute and assign a different value of name to each clone (and then ask each of them to say its own name)? If this is possible, how?

What have you tried that didn't work?

See attached program.

Post a project example, link, or screenshot:

Cloning Sprites program

Remix

is what you looking for ?

Yes, that's what I was trying to do. One question:

  • What if I don't want the original to show itself?

you can hide it, i will modify the remix...

just make the sprite show before cloning, then after cloning, hid the sprite, or just hide the sprite at the beginning, and then
[scratchblocks]
when I start as a clone
show
[/scratchblocks]

image

I added a script near the bottom of mine, and I want the prompt to be asked once per key press, not five times. How can I limit the ask to just once?

P.S. Is there any document I should be reading that explains all of this? (Please don't say it's the Reference Manual.)

you can just make it run for only the original sprite, just do this
untitled script pic (7)
and yes, I know this isn't the best way to test for a clone, because you can set temporary to false for a clone, but he's most likely not gonna do that.

[Edited]

The desired behavior is that nobody moves on the second (or subsequent) time around, until the user has given a new answer to the question. I was able to get this by incorporating the move logic into your if-block. A more fundamental question is, why is this script being executed for every sprite in the first place?

Hat blocks get triggered for every clone/sprite. Why? Well, clones are just temporary sprites, who's parent is the original sprite. A clone also inherits all the scripts/variables from the original sprite.

Got it. And with that new understanding, I'm now able to get the behavior I want by moving the new script from the (parent) Sprite to the Stage (where it executes only once per key press). Thanks.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.