I’ve tried two different equations for moving bullets. They both seem to work exactly the same way. They both have the same problem.
shooting at 45 degree increments. every one looks perfect except 310 and 135. They both slip in x. I can do -135 and it works, but those two directions slip. Also angles in that whole 90 degree cone are messed up.
Any idea what would cause that? Is it a bug? Help please!
The bullet should move the bottom left corner of the stage, but it slips in x to the left as it moves.
var dx:Number ;
var dy:Number;
var rot:Number = 135;
var speed:Number = 30;
var lastTime:Number;
function Bullet() {
test.x = 200;
test.y = 200;
test.rotation = rot;
// get speed
dx = speed*Math.cos(rot*Math.PI / 180)
dy = speed*Math.sin(rot*Math.PI / 180)
// set up animation
lastTime = getTimer();
addEventListener(Event.ENTER_FRAME,moveBullet);
}
function moveBullet(event:Event) {
// get time passed
var timePassed:int = getTimer()-lastTime;
lastTime += timePassed;
// move bullet
test.x += dx*timePassed/1000;
test.y += dy*timePassed/1000;
}
Bullet();