Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 11-24-2008, 03:45 PM   #1
Registered User
Join Date: Nov 2008
Posts: 15
Default shooting multiple bullets (AS3)

Hello everyone,
I'm trying to make my platform game character shoot a gun, my character and gun are one movieclip and the bullet is another. The bullet mc starts on a blank frame with a stop() function, when I press the space bar the bullet mc plays from frame 2 which is a motion tween of the bullet quickly moving across the page. I've set the bullet's y and x values relative to the character mc so that the bullet always comes from the gun.

My issue is that if I press the space bar a bullet will fly out of the gun (great!) but if I press the space bar again, the first bullet disappears and the bullet animation starts again. I want to be able to shoot a new bullet every time I press the space bar without effecting the bullets that have already been shot.


if(event.keyCode == Keyboard.SPACE)

bullet_right_mc.y = (ball_mc.y -38);
bullet_right_mc.x = (ball_mc.x + 253);



ryrocks is offline   Reply With Quote
Old 11-24-2008, 05:51 PM   #2
throw a trace() in there
Join Date: Dec 2006
Posts: 1,982

I would maintain an array of bullets, create a Bullet class, and do something like this:

ActionScript Code:
var newBullet:Bullet = new Bullet(x,y); bulletList.push(newBullet);
rrh is offline   Reply With Quote
Old 11-25-2008, 12:29 AM   #3
Registered User
Join Date: Nov 2008
Posts: 15

Cheers for your help dude.
I added the class bullet and set a var bulletVar:

var bulletVar:bullet = new bullet();
spaceDown = true;
bulletVar.y = (ball_mc.y -38);

Thanks again!
ryrocks is offline   Reply With Quote

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
loading multiple as2 in as3 problems? player bug? Project1.exe ActionScript 3.0 5 07-28-2008 01:05 PM
AS3 loading multiple library items into an array... jonshai ActionScript 3.0 3 03-05-2008 07:44 PM
sending events to multiple listeners in as3 sebacuello ActionScript 3.0 0 05-31-2007 04:05 PM
trouble making multiple bullets über_soldat ActionScript 2.0 8 06-06-2006 12:25 PM
shooting Multiple bullets jasonpeinko ActionScript 1.0 (and below) 1 02-10-2006 03:46 AM

All times are GMT. The time now is 09:23 AM.

Follow actionscriptorg on Twitter


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.