Adding scripts to Shield and Shield Life
Shield protects and is also protected by the Spaceship. Each time the enemy sprite collides into it, Shield will lose one grid of power, displayed by Shield Life.
When the power is gone (all red), Shield is destroyed and the game is over.
Shield Life displays the shield power grid by changing its costumes, each at a power grid damage level. The technique to display damage level with costumes is to match the costume number with the number of hits. Scratch costumes start from one, instead of zero, so costume#1 depicts zero hit, costume#2 for one hit, and so on.
Prepare for lift off
Shield Life has two local variables: num_shield_hits
and num_max_hits
. The number_shield_hits
variable tracks how many hits the Shield sprite has suffered, and the num_max_hits
variable tells the maximum number of hits that Shield can take before its complete destruction.
Engage thrusters
The following steps are used to build the scripts for the Shield sprite:
Add the when <green...