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

So you are making your first game, a space invaders type, and you have everything done, except your little spaceship at the bottom of the screen can't shoot the bad aliens that are flying towards him. This tutorial will teach you how to do just that.

Note: This tutorials assumes you are shooting from down to up, if you are shooting from left to right just switch y<->x and height<->width, or if you are going from top to bottom make all the y's negative

To start out we need some symbols:

-a ship sprite (movie clip) and put this on the main timeline and name it.

-a bullet sprite (graphic or movie clip)

-a bullet animation (movie clip)

the bullet needs to be designed in this format: two blank keyframes at the beginning, followed by the bullet sprite starting at (0,0) and then the appropriate number of frames later at (0, -(50 greater than your stage's height) ). Then put a motion tween inbetween the third and last frames so it appears that the bullet is moving.

Then, in frame 1 of the bullet animation, put "stop()" (that is action code: click on the frame and then press F9). Then, in frame 2 of the bullet animation, put the code: "this._x=_root."name"._x" where "name" is replaced with the symbol name you gave your ship on the main timeline.

Then put your bullet animation on the main timeline and give it a symbol name.

Now, click on your ship symbol and add this action code (press F9) within the "onClipEvent(enterFrame) {" parameter (if you don't have this you need to add it and add an end squiggly bracket):

if(Key.isDown(Key.SPACE)) {



Where "name" is the symbol name you gave your bullet animation. This assumes that you want the space key to fire, if you don't, change "Key.SPACE" to the appropriate key.

I hope that this tutorial has helped you! Please email me if you have any problems and check out my website! Thanks! --Luke

» Level Basic

Added: 2006-11-07
Rating: 5 Votes: 10
» Author
Has a game website: zazeran.com . Has been using Flash for six months and Java for two years. Please check out his website.
» 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.