Game Development Reference
In-Depth Information
Engage thrusters
The following steps are used to build the scripts for the Shield sprite:
1. Add the
when <green lag> clicked
block, but before the player starts to play, just
hide (using
hide
).
2. The next script starts with
when I receive <game_start>
. First, add
switch costume
to <normal>
, then
go to x: () y: ()
; fill in the values
7
and
-110
respecively. Finally,
add
show
.
3. To define the behavior during gameplay, start with
when I receive <shield_hit>
,
make it real by adding
switch costume to <hit>
,
wait <frame_rate> secs
, then
switch costume to <normal>
.
4.
If the shield is destroyed, the Shield sprite would receive the
shield_destroyed
message. Therefore, add
when I receive <shield_destroyed>
,
switch costume to
<destroyed>
, and
stop <other scripts in sprite>
.
The final script looks like the following screenshot:
Next, we will create the scripts for the Shield Life sprite.
Before the game starts, this sprite will hide. At the start of the game, it iniializes its
local variables.
The following steps handle the
<green lag>
click and
game_start
messages:
1.
Add the
when <green lag> clicked
block, but before the player starts to play, just
hide (using
hide
).
2.
The next script starts with
when I receive <game_start>
message. First add
go to x:
() y: ()
with the values
-51
and
-120
, then
set <number_max_hits> to ()
with the
value
7
, and
set num_shield_hit to ()
with the value
0
. Next, add
switch costume to
<0 hit>
, then
go to front
, and
show
.