Game of Tag
Let’s make use of these names we’ve given our sprites to make them interact with each other. We want one of the characters to react if the two characters touch. In the last step, we showed an example with Cat and Mouse. We can add following script to the Mouse sprite to say “OH NOs!!!” when it touches the Cat.
Note: One really important thing to note here is that once we click the green flag, the script above will always be running: notice that it always has a yellow outline.
Compare this to the script below that would only run once when you click the green flag. The functionality above is often called an infinite loop, and can be very helpful when we want something to continue running forever.
Try It Out!
Replicate the two commands illustrated in the screenshots above using your own sprites. Remember that blocks are color coded according to their tabs. Experiment with these and other codes to make your program unique.