i'm making a flash/actionscript shooter game, and this is a class i created for the bullets.
class Class.Bullet {
public static var self:MovieClip;
private static var interval;
public function Bullet(X, Y) {
self = _root.createEmptyMovieClip('self', _root.getNextHighestDepth());
self._x = X;
self._y = Y;
self.beginFill(0xFFFFFF);
self.moveTo(-2, 0);
self.lineTo(2, 0);
self.lineTo(2, 10);
self.lineTo(-2, 10);
self.lineTo(-2, 0);
self.endFill();
interval = setInterval(move, 1);
}
private function move() {
self._x++;
}
}
it works okay, except for some reason, beyond my understanding, each time a new bullet is created "setInterval" gets passed onto the next bullet in addition to the new setInterval.
in other words, when i shoot a second bullet, the first bullet stops moving, and the second bullet moves at twice the speed.
cheers!!
P.S: i'm using as2