First time here? First time here? Newsletter Signup Newsletter
Login | Register | 651326 Members and growing! | Flash Jobs
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)) {

_root."name".play()

}

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
(10 being the highest)
» 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!

Comments

  • There are no comments yet. Be the first to comment!

  • You must have javascript enabled in order to post comments.

Leave a Comment
  • Your email address will not be published. All fields are required.
Featured Flash FLA
» Author: work2survive
» Title: Girl Walking 1kb
» Description: Walking girl, animation just takes 1kb, using high heels shoes, and fashion model attitude.
Featured Sound Loops
Image for equalize

Audio Player

» Author: BoxCat
» Title: CPU Talk
» Description: From the cyberpunk RPG, "Nameless: the Hackers" Completely Free to use! Keywords: edm hip hop rap electronic mysterious mission hacking chase exciting spy ios ambient chilling love happy sad angry suspense
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: nathan
» Description:

A recorded sound of the Dimensional Fork Gate.