Discuss Scratch

frodewin
Scratcher
500+ posts

Detect if a sprite is touching one of its clones

I tried with the
touching?
block, but it did not work.

Since the drop-down list of the touching block does not contain the own name of the sprite, I constructed the touching block in another sprite and dragged it over to the sprite with clones. However, the block always reports true.

Anybody has an idea how I can detect if a sprite is touching one of its clones?

Last edited by frodewin (Jan. 11, 2016 12:15:48)

ChocolatePi
Scratcher
1000+ posts

Detect if a sprite is touching one of its clones

This Wiki article might interest you http://wiki.scratch.mit.edu/wiki/Detecting_Clones

ChocolatePi
PhysicsWhizz
Scratcher
100+ posts

Detect if a sprite is touching one of its clones

frodewin wrote:

I tried with the
touching?
block, but it did not work.

Since the drop-down list of the touching block does not contain the own name of the sprite, I constructed the touching block in another sprite and dragged it over to the sprite with clones. However, the block always reports true.

Anybody has an idea how I can detect if a sprite is touching one of its clones?

If I were you, I would make a list which stores the X and Y positions, ID, etc. of the clone.
You can check each item of the list and see if the X and Y positions of the clone overlap with the X and Y of the main sprite. If it is, it is touching it and if it is not it's not.

Last edited by PhysicsWhizz (Jan. 11, 2016 13:05:52)

BKFighter
Scratcher
1000+ posts

Detect if a sprite is touching one of its clones

Just have each clone see if its touching the sprite. Or does that not work? I don't remember.
AwesomeSmilee
Scratcher
500+ posts

Detect if a sprite is touching one of its clones

BKFighter wrote:

Just have each clone see if its touching the sprite. Or does that not work? I don't remember.
<touching [main sprite v]> doesn't work.

Last edited by AwesomeSmilee (Jan. 11, 2016 17:37:19)

footsocktoe
Scratcher
1000+ posts

Detect if a sprite is touching one of its clones

It shouldn't be possible because the clone is the sprite, just a duplicate of it. So it is always touching itself.

Simple workaround: Duplicate the original sprite and have it follow that sprite around on top of it. You WILL be able to detect touching that sprite.
Vienradze
Scratcher
500+ posts

Detect if a sprite is touching one of its clones

whenIstartasaclone
change colororeffectby5
foreverifcoloristouching?then
alberto85
Scratcher
14 posts

Detect if a sprite is touching one of its clones

Hi!
I think it depends a lot on what you want to do… but:
I tried for a while to detect clone collisions when the sprites were moving freely (not after player input), but then I gave up, and looked for another way.

Instead of clones, I used lists of X-positions and Y-positions, as PhysicsWhizz suggested. Every cycle there is just one (hidden) sprite, without clones, moving around at each recorded position and making a stamp. In this way it looks like it's a lot of sprites moving.

If you want you can have a look at my project “More Bouncing Balls” here.

Hope this helps.

Last edited by alberto85 (Jan. 11, 2016 23:21:32)

Powered by DjangoBB