基本上发生的事情是当我发射子弹时,它会产生子弹。但是,如果我在项目符号仍在屏幕上时再次单击,它会删除项目符号并创建一个全新的项目符号。所以现在一次只能在屏幕上显示一颗子弹。我该如何解决?库中的项目符号的实例名称为“项目符号”
package
{
public class GameEnter extends MovieClip
{
public function GameEnter()
{
addEventListener(MouseEvent.MOUSE_DOWN, shootBullet);
}
public var _bullet1:bullet = new bullet;
public var angleRadian = Math.atan2(mouseY - 300,mouseX - 300);
public var angleDegree = angleRadian * 180 / Math.PI;
public var speed1:int = 10;
public function shootBullet(evt:MouseEvent)
{
_bullet1.x = 300;
_bullet1.y = 300;
_bullet1.angleRadian = Math.atan2(mouseY - 300,mouseX -300);
_bullet1.addEventListener(Event.ENTER_FRAME, bulletEnterFrame);
addChild(_bullet1);
}
public function bulletEnterFrame(evt:Event)
{
var _bullet1 = evt.currentTarget;
_bullet1.x += Math.cos(_bullet1.angleRadian) * speed1;
_bullet1.y += Math.sin(_bullet1.angleRadian) * speed1;
_bullet1.rotation = _bullet1.angleRadian*180/Math.PI;
if (_bullet1.x < 0 || _bullet1.x > 600 || _bullet1.y < 0 || _bullet1.y > 600)
{
removeChild(_bullet1);
_bullet1.removeEventListener(Event.ENTER_FRAME, bulletEnterFrame);
}
}
}
}