Making Level 1

This first level is going to be an easy level for the player. We are going to arrange our sprites into the scene. This is only our first level, so we will only include two asteroids in this level, adding more in later levels as the game goes on.

Making Level 1

In the previous screenshot, you can see the level put together with two asteroids. After I did this, I duplicated the Big Asteroid actor in the Inspector, renamed it Small Asteroid and sized it down by half. So instead of 50 x 50 px, the Small Asteroid is 25 x 25 px. I created these Small Asteroid actors because when you shoot the Big Asteroids they will spawn three smaller asteroids like the original game. Cool huh?

  1. Now, we are going to create a score actor. So, create a new actor and name it Score, open it up and change the Width to 100 and Height to 20.
  2. Go back to the level editor, click the Attributes tab and click the + button to create a new attribute. When the selector comes up, choose Integer, and rename it to Score.
  3. Now, go back to the Actors tab and double-click the Score actor, so we can add in some behaviors.
  4. Add a Display Text behavior, and click the e beside the textbox, then click the down arrow to expand the Expression Editor and click Game and then Score, or you can even type in game.Score, and then click the green arrow to accept the changes. Change the size to 15, and keep the color white.
  5. Now, we have to change the alpha of the actor, but we are going to hide it when the game starts to make it easier to arrange in the level editor.
  6. All we have to do is drag in a Change Attribute behavior, change the self.Color.Alpha to 0.
    Making Level 1
  7. Test the level to make sure it works and disappears when you play. If not, go back to double-check the behaviors and see if you typed everything in properly.
  8. Now, we have to edit the asteroids. Double-click the Big Asteroid, so we can edit it. Add in a Rotate behavior and set the Speed to random(-50,50), so this will make the asteroids rotate at different speeds. The negative number will make it rotate counter-clockwise and the positive number will make it rotate clockwise.
  9. Now, add in a Move behavior, and change the Direction to random(0,360), then change the Speed to random(5,50). This will make the asteroid move in a random direction from 0 to 360 degrees, and then the speed will make it move slow or fast.
Making Level 1

What did we do? Just to recap, we added custom behaviors to randomize the movement of these asteroids; we varied the rotation, the speed, and the direction they move in with simple behaviors.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.226.185.196