[mx] laser shooter

Hi, I’m fairly new at flash,

I’m working on a new project, its a side scrolling game where an airplane (user) has to shoot down a bunch of other enemy planes. I was wondering how to create an AS to shoot lasers from the nose of the plane… any help would be appreciated…:crazy:

thanks in advance!

Tute is on the way :slight_smile:

HAHA, that is kinda funny. Kirupa just mentioned the tute he was working on about something like that :stuck_out_tongue:

[swf=“http://www.fantom-stranger.com/~mentalconcepts/freedomFighter.swf height=400 width=550”][/swf]

You mean something like this?

yea, like that playamarz, except that the ship is able to move on the x axis… other than that, its exactly the same… can i see the AS you used, it would be really helpful,

thanks=)

I tried using this AS…

lsrSpd = 0;
laser._visible = false;
bullet._x = px;
bullet._y = py;
px = user._x;
py = user._y;

bullet.onEnterFrame = function() {
if (Key.isDown(Key.SPACE)) {
lsrSpd = 10;
px += lsrSpd;
this._visible = true;
}
}

the laser follows the nose of the plane and when the space bar is pressed, the laser becomes visible. The thing is that the laser doesn’t move accross the screen, it keeps following the nose of the plane…

any help would be great!(-:

Here… Well nevermind… Server is down for now… But… Here I’ll post my script…

This is found in the first frame :



MovieClip.prototype.fireShot =  function (startx, starty, xdir, ydir)
{
	duplicateMovieClip(this, "bullet"+next, next);
	_root["bullet"+next]._x = startx;
	_root["bullet"+next]._y = starty;
	_root["bullet"+next]._xvel = xdir;
	_root["bullet"+next]._yvel = ydir;
	if(next<1000){next++;}else{next=0;}
}
_root.stanShot.onLoad = function()
{
	mouse.hide();
	next = 10;
	addon = 0;
	stanTimer = 0;
	shotTimer = 0;
}
_root.onEnterFrame = function()
{
	_root.plane._y = _root._ymouse;
	_root.addongun._y = _root.plane._y;
	if(Key.isDown(48))
	{
		addon = 0;
		removeMovieClip(addongun);
	}
	if(Key.isDown(49))
	{
		addon = 1;
		removeMovieClip(addongun);
		duplicateMovieClip(spreader, "addongun", 3000);
		_root.addongun._x = _root.plane._x;
		_root.addongun._y = _root.plane._y;
	}
	if(Key.isDown(50))
	{
		addon = 2;
		removeMovieClip(addongun);
		duplicateMovieClip(macgun, "addongun", 3000);
		_root.addongun._x = _root.plane._x;
		_root.addongun._y = _root.plane._y;
	}
	if(Key.isDown(51))
	{
		addon = 3;
		removeMovieClip(addongun);
		duplicateMovieClip(bag, "addongun", 3000);
		_root.addongun._x = _root.plane._x;
		_root.addongun._y = _root.plane._y;
	}
	if(stanTimer>0){stanTimer--;}
	if(shotTimer>0){shotTimer--;}
}
_root.onMouseDown = function()
{
	if(stanTimer == 0)
	{
		_root.stanShot.fireShot(plane._x+30, plane._y, 7.5, 0);
		stanTimer = 10;
	}
	if(addon == 1 && shotTimer == 0)
	{
		_root.stanShot.fireShot(plane._x, plane._y+20, 7.5, 0);
		_root.stanShot.fireShot(plane._x-3, plane._y+28, 7.5, 3.5);
		_root.stanShot.fireShot(plane._x-10, plane._y+34, 7.5, 6.25); 
		shotTimer = 18;
	}
	if(addon == 2 && shotTimer == 0)
	{
		_root.stanShot.fireShot(plane._x+5, plane._y+25, 8.5, 0);
		shotTimer = 2;
	}
	if(addon == 3 && shotTimer == 0)
	{
		_root.stanShot.fireShot(plane._x, plane._y+25, 7.5, 0);
		_root.stanShot.fireShot(plane._x+5, plane._y+25, 7.5, 0);
		_root.stanShot.fireShot(plane._x+10, plane._y+25, 7.5, 0);
		_root.stanShot.fireShot(plane._x+15, plane._y+25, 7.5, 0);
		_root.stanShot.fireShot(plane._x+10, plane._y+20, 7.5, 0);
		_root.stanShot.fireShot(plane._x+10, plane._y+30, 7.5, 0);
		shotTimer = 28;
	}
}


This piece of code howveer… Is ;ocated int he bullet movieclip…



onClipEvent(load)
{
	this._xscale = 50;
	this._yscale = 50;
}
onClipEvent(enterFrame)
{
	this._x += this._xvel;
	this._y += this._yvel;
	
	if(this._x > 550)
	{
		removeMovieClip(this);
	}
}


Have fun… hehe… It should be pretty readable… Albeit… If you need me to break it down some… I can.