Goal:
Now we have lives to lose and a broadcast message when you run out, but we still need to tell the game how to subtract lives and how to activate our hit animation.
Any time you are hit by an enemy, you need to lose a life. We have three enemies, TIE-Fighter, TIE-Bomber, and the Star Destroyer.
We are going to start with the TIE-Fighter.
Steps:
- From the sprite menu, select the sprite called TIE_Fighter and find the block of code that controls what happens when the TIE-Fighter touches the laser, the x-wing, or the bomb.
- From Variables, place a change by block into the IF statement that controls what happens when the TIE-Fighter hits the X-Wing after the change Score block.
- Set the variable to Lives and the amount to -1.
- From Events, place a broadcast block between the change Lives and the switch costume blocks, and set it to Hit.