ForumsProgramming ForumBullet Placment Issue AS2

2 3114
ShadowVoxx
offline
ShadowVoxx
12 posts
Nomad

Hey, I'm having trouble with the placment of the bullets using the code. Right now they don't follow the placement comands and spawn at 0,0. I'm sure it's just a syntax error or somthing stupid but could some one take a look and tell me what they reckon.

&ltre>
function fire() {
myRadians=Math.atan2(_root._ymouse - this._y,_root._xmouse - this._x);
myDegrees=Math.round(myRadians * 180 / Math.PI);
var bulletFire=_root.attachMovie("Bullet","Bullet" + _root.getNextHighestDepth(),_root.getNextHighestDepth());
bulletFire._x=_root.Ship._x;
bulletFire._y=_root.Ship._y;
bulletFire._rotation=myDegrees;
bulletFire.dirx=bulletVel * Math.cos(myDegrees * Math.PI / 180);
bulletFire.diry=bulletVel * Math.sin(myDegrees * Math.PI / 180);
bulletFire.onEnterFrame=function() {
this._x += this.dirx;
this._y += this.diry;
};
}

  • 2 Replies
PixelSmash
offline
PixelSmash
566 posts
Nomad

Well, can't see that much wrong with your code... why not try tracing what the _x is, and what it should be? (the _root.Ship._x) Perhaps that helps finding out what's wrong

ShadowVoxx
offline
ShadowVoxx
12 posts
Nomad

I changed _root.ship to this._x and it works great now. Does anyone know what would be the function to change the fire button from space to mouseDown?

Showing 1-2 of 2