Game Development Reference
In-Depth Information
4.
Name the new sprite
finish
.
5. Go to the
Scripts
tab of the
finish
sprite.
6. Add a
when <green lag> clicked
block.
7. Atach a
set <ghost> effect to ()
block to make the line invisible; fill in the value
100
.
8. Then, we go to the
Scripts
tab of
player1
to add to the script there.
9. We create two more variables named
lap
and
touchFinish
. Both
variables should apply only to this sprite (using
only to this sprite
).
10. Click on the check box for the
lap
variable to make it visible on stage.
Drag the display to the top-right corner of the stage.
We will check for collisions with the finish line and increase the lap variable accordingly
to count the number of laps the players have driven:
1.
Get an
if () then () else ()
block to form the basic structure of the script. This block
will check when a kart is or isn't touching the finish line and set the appropriate
variable correspondingly.
2.
Inside the
if
slot, place an
if () then
block (
without an "else"
). With this block, we will
count the number of laps completed.