Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to stop a clone from inheriting a message

Tags:

mit-scratch

I have this code:

code

But whenever the shoot message is sent to the bullet sprite, and there is a clone on the stage that hasn't hit it's target yet, the clone will be sent back with the go to x: (xOfTower) y: (yOfTower) block. Is there some way to prevent a clone from receiving a message while the real sprite does?

like image 915
stonefish Avatar asked Oct 30 '25 16:10

stonefish


2 Answers

Clones have their own copy of local variables!

To solve this problem you can add a new variable but be sure to check 'For this sprite only'. Otherwise there will only be 1 variable.

enter image description here

Now a new variable will be created for each clone. Give the variable a value to label it as clone and add a guard on your message action.

scratch code

like image 62
call-me Avatar answered Nov 04 '25 01:11

call-me


There is no way to prevent all sprites receiving the broadcast message. You have to write code to make those that shouldn't act on it, ignore it. In this case I suggest it is easier to do the following:

Suggest moving the two lines

point in direction (directionOfTower)
go to x: (xOfTower) y: (yOfTower)

into the when I start as clone block.

like image 27
Morag Hughson Avatar answered Nov 03 '25 23:11

Morag Hughson