I am tryin to create an asteroids game:
When I fire the bullet everything is fine but when the second bullet is fired the first one stops and the second one is fine…etc.
Seemingly it is removing the properties from the first and placing them on the other when another child is added.
Here’s my code:
function keyDownHandler(event:KeyboardEvent):void{
if (event.keyCode == 32){
newBullet = new bullet()
addChild(newBullet)
trace(newBullet.numChildren)
for(var a:int = 0; a < newBullet.numChildren;a++){
newBullet.x = spaceship.x
newBullet.y = spaceship.y
newBullet.rotation = spaceship.rotation
newBullet.addEventListener(Event.ENTER_FRAME, bulletCode);
}
}
}
function bulletCode(event:Event):void{
xBulletVel = Math.sin(radAngle)
yBulletVel = Math.cos(radAngle)
newBullet.x += xBulletVel
newBullet.y += (yBulletVel)*-1
}
thanks 