This time, let's make the cat "nom nom" the mouse.
But as a start, let's just make the mouse disappear whenever the cat touches the mouse.
So let's add an "if" statement inside the "forever" block.
Go to the control section in the scripts, and drag the "if" block into the "forever" block.
Remember, it's in a forever loop so that it checks again, and again, and again, and again and... again.
Now, in the sensing section drag the "touching" block inside of the "condition" part of the if statement.
If the condition is true, this happens, if it isn't, check again.
Click on the little arrow on the "sensing" block and select "mouse1" (Which is the mouse sprite).
We want to tell the mouse to do something, so we use broadcast (inside the events section)
If you tell another sprite to receive the message, then the sprite will do whatever you tell it to when it receives the broadcast.
Drag the broadcast block inside of the "if" block.
Your code should now look like this:
Now, let's change the mouse's scripts.
In the sprites section, click on the mouse sprite that we made last time.
In the events section, drag the "When I Receive" block onto the scripts section.
Go to the looks section, and drag "hide" under the "When I Receive" block.
Wait... when you click the green flag to try again, the mouse is gone!
Come on and drag the "show" block just above the "hide" block under the "When Green Flag Clicked" block.
Now try it out!
Next time, we'll add scoring and re-spawning!
"Nom Nom" tasty mouse :-)ReplyDelete
Messages are very useful; thanks.