Step 6: Laser Starting Code

Goal:


We now have a mechanism in our game that tells it when we want to clone, or fire, our laser. We still need to tell the laser what to do though.

The first thing we need to tell it is where it is placed in the game. We are going to hide the laser behind the X-Wing and have it follow the X-Wing no matter where it goes so that when we do fire it, it looks like it come out from the X-Wing.

Steps:

  1. From the sprite menu, select the one called Red_laser.
  2. From Events, place a when green flag clicked block.
  3. From Control, place a forever block.
  4. From Looks, place a hide block inside of the forever block.
  5. From Motion, place a go to random position block, and change it to X_Wing.

Code:


Click to replay