First time here? First time here? Newsletter Signup Newsletter
Search tutorials
Author: Luke Knepper | Website: http://zazeran.com

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:

on(release) {

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

Added: 2006-12-13
Rating: 4.17 Votes: 52
» Author
Luke is an active Java, PHP, and Flash programmer, website designer, and game developer. Has much programming experience.
» Download
Download the files used in this tutorial.
» Forums
More help? Search our boards for quick answers!
Featured Flash FLA
» Author: Inocreato
» Title: RaiseTheBlocks
» Description: Raise all the blocks to win the game
Featured Sound Loops
Image for equalize

Audio Player

» Author: TomCat Carty
» Title: The Wood
» Description: Just a little game ending or it can maybe be looped. Recorders with music box and percussion to give the feel of well, I don't know, the woods? Free to use, just credit me. thank you
Latest Font
» Author: Fábio FAFERS
» Description: I created this font for free use. Everyone can apply it in personal or business texts. Its free, but I want to be communicated in case of business use. Donations are accepted to keep the project of free fonts alive! Thank you all
Featured Sound Fx
Image for equalize

Audio Player

» Author: Davisigner
» Description: Hmm... what to say about this one? It's reminiscent of the closing notes of the opening music from the Three Stooges done in a church organ style with a closing cymbal crash. I'll give this one away gratis, but feel free to check out my free loops and potential upcoming license-mandated ones over in the respective part of Flashkit.