I made a scratch game where I have a dog (moves with arrow keys) that is trying to catch a butterfly (randomly moving around the screen) I also have 2 tree sprites. If the dog hits the tree then the dog then moves to a random location on the game (a punishment for hitting the tree) Another statement I wanted to add was to have the butterfly also decrease in size if the dog hits the tree (making it harder to catch) but I was unable to figure out how to adjust 3 sprites in a statement. I tried On the butterfly sprite IF (xposition of dog1 = xposition of tree1) and (yposition of dog1 = yposition of tree1) THEN change size by -50 Then repeated this for tree 2. I cant really think of another work around. I think settings the x and y as my conditions may be too specific. Hopefully that makes sense! I added a picture of the game if that helps. Thank you.
1 Answer
There is a "broadcast" block in the events category which can be used to do this.
If you have a collision check already working in your dog, you can add a broadcast block to the function that moves the dog to a random location.
You could, for example, broadcast a "collision" message.
Then, on the butterfly, you need to add a listener block, which is also in events.
That way you can define something to do each time the butterfly receives a "collision" message.
Messages are broadcasted to all the entities in your game, you only need to broadcast them an setup listeners to be able to pass messages between your sprites.