SCRATCH GOLD II
SCRATCH GOLD I
2 of 3

2.08 Lasers!

To your game a little harder to complete, you are going to add lasers!

Add a new sprite to your game and call it laser. It should have two costumes: one called ‘on’, and one called ‘off’.

screenshot
screenshot

Place your new laser sprite between two platforms.

screenshot

Add code to your laser sprite to make it switch between its two costumes.

laser sprite

If you prefer, you can change the code shown above so that the sprite waits a random amount of time between costume changes.

Finally, add code to your laser sprite so that the laser sprite broadcasts a ‘hit’ message when it touches the character sprite.

You don’t need to add any extra code to your characters sprite, because the character sprite already knows what to do when it receives the broadcast 'hit'!

Test out your game to see if you can move the character past the laser. If the laser is too easy or too hard to avoid, change the wait times in the code for the laser sprite.

×
×

Cart