• Home
  • Free Tutorials
  • Free Video Tutorials

Adobe Photoshop
Autodesk 3ds Max
CSS
Flash
Help Center Live
iPhone
Joomla
Make Money Online!
Mambo
mIRC
Outlook Express
SEO / SEM
Simple Machine Forum
Target Explorer

Space Shooter - Shooting

Category : Flash Views : 85666
Version : 8 Rating : 
3.0/5 (139 votes)
  • Currently 3.01/5
  • 1
  • 2
  • 3
  • 4
  • 5
Type : Text Source File: space-shooter-shooting.zip
Result: See the result


<<< PreviousIndex SeriesNext >>>

Previous | 1 | 2 | Next

This tutorial is a series of tutorials that will teach you how to create Space Shooter Game. The tutorial is divided in 5 parts. If you haven't learned the previous tutorials, please see Space Shooter Flash Game

This is the second part of the tutorial and we are going to enable the ship to shoot.

Previously we made our ship fly; now we are going to make it shoot and set limits to where it can go.

First we need to make our bullets, right click the library tab, select "New SymbolÂ…" and give it the name "Bullet".

Before clicking OK, click Advanced, select "Export for Actionscript" and make sure the identifier is "Bullet".
Free Flash Tutorials, Free Flash Game, Space Shooter Game, Shooting

We do this because we need to export the Bullet Movie Clip during running time to create many bullets and we will use the name determined in identifier to call it later.

Draw a small bullet, and position it like this:

Free Flash Tutorials, Free Flash Game, Space Shooter Game, Shooting
This is called registration point, in the stage this is the position of the Bullet Movie Clip.

Now open the actions window of the first frame of the Movie Clip and paste this code:
this.onEnterFrame = function() { this._x += 12; if (this._x > 550) { this.removeMovieClip(); } }
"this" is the Movie Clip instance, so if we duplicate 100 bullets each bullet will have the same code.

this._x += 12;
Every frame, the bullet will move 12 pixels to the right.

if (this._x > 550) { this.removeMovieClip(); }
If the bullet passed the limits of the screen (550px) it's no longer visible, so we remove it by using this method "removeMovieClip()"

Now go to the main timeline, select the first frame and open the actions windows. You will see the previous codes that we have written. Add this code to the old one so we can fire our bullets:
var i = 0; this.onEnterFrame = function() { . . . else if (Key.isDown(Key.DOWN)) { Ship._y += 5; } if (Key.isDown(Key.SPACE)) { i++; _root.attachMovie("Bullet", "Bullet" + i, _root.getNextHighestDepth()); _root["Bullet" + i]._x = Ship._x + 3; _root["Bullet" + i]._y = Ship._y; } }


del.icio.us digg it Reddit Stumble Upon Technorati

Previous | 1 | 2 | Next

<<< PreviousIndex SeriesNext >>>
How to Video Tutorials on software by Helpvids.com

Video tutorial: Forex trading



Sponsors



Advertisement









Studio | Advertisement | About Webzo | Contact Webzo | Terms of Use | Free Video Tutorials by Helpivds

Copyright © 2007 NR Concepts Ltd. All rights reserved.