Hi! This tutorial will teach you how to make a basic space invaders game a lot like this one in Flash 8. So, let's get started!
First you will need to set up your main timeline. You will want to select the size, by clicking on the button in the bottom inspector. A good size varies, for a space invaders game 600x600 would probably be pretty good. I suggest you make multiple layers (click on the new layer button in the timeline at the top), at least two named "game" and "background" and you may have even more, but this is not mandatory, it just makes the game more organized. Next, make a second and third key frame in ALL of the layers. Now you should have three frame sequences. In the top frame of each sequence, put the code "stop()" (click on the frame and press F9 to open up the code editor). In the first frame, also put this code: "var score: Number = 0" and on a newline "var life: Number = 100". What this does is make to variables, score and life, that can be accessed anywhere in the game. You can do this for as many variables as you want if your games get complicated. To access these variables through code, just put "_root.varName". (Note: In a specific symbol / object, you can make a variable just by typing the name and setting it equal to anything. However, this variable is only easily accessed by the specific object, so it is better to make a global variable in the main timeline.) The first frame will be the opening screen. You may design this however you want, putting the title and a bunch of cool effects, but you must have a button. Before you design anything make a button using the drawing tools that you want to be the start button. (Note: If you have any text make sure to select it and press Ctrl+B twice to break it apart!) Now select the whole button image and press F8. This will convert it to a symbol. As a name type "Start btn" and check the button type. now your drawing will be highlighted in blue. Select it, and press F9 and insert the following code:
This means "When the button is released from a mouse press, go to Frame 2 and stop." If you test run your game, you will see that the button disappears when you click it! This is because the button is not in the second frame. Now make a game over frame in the third one. To make a text field that shows your score, choose the text field tool, and draw one. In the bottom, with the field selected, choose "Dynamic Field" and under the "Var" field put "score". Now that you have the basics set up, you will need to make the following sprites as movie clips: a tank sprite (you), a bullet sprite (your bullet), a ship sprite (the invader(s)). To make a new symbol (sprite) press Ctrl+F8. Then select "Movie Clip" and type in the sprite's name (i.e. tank, ship1...). Now that you have those done, go back to the main timeline. In the second frame (the game frame) place the bullet off the stage (drag and drop the bullet symbol from the library, the left inspector), the tank on the stage at the approximate y location you want it, and the invader off the stage. Next I will show you all the code you need to add!
|» Level Basic|
Rating: 4.3 Votes: 50
|Luke is an active Java, PHP, and Flash programmer, website designer, and game developer. Has much programming experience.|
|Download the files used in this tutorial.|
|Download (0 kb)|
|More help? Search our boards for quick answers!|