我不知道下一步该做什么。现在,当我单击时,它会添加子弹并将其旋转到正确的角度,但我不知道如何让它开火。我想让子弹射到鼠标指向的地方。谢谢!PS:对不起,如果代码是混乱的。
package
{
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.TimerEvent;
import flash.events.KeyboardEvent;
import flash.utils.Timer;
import flash.text.Font;
import flash.events.MouseEvent;
import flash.text.TextDisplayMode;
import flash.text.TextExtent;
import flash.text.TextField;
import flash.text.TextFormat;
import fl.motion.easing.Back;
import flash.display.DisplayObject;
public class GameEnter extends MovieClip
{
public var _bullet:bullet;
public function GameEnter()
{
stage.addEventListener(MouseEvent.MOUSE_DOWN, shootBullet);
stage.addEventListener(MouseEvent.MOUSE_UP, removeBullet);
}
public function init()
{
_bullet = new bullet();
addChild(_bullet);
_bullet.x = stage.stageWidth / 2;
_bullet.y = stage.stageHeight / 2;
addEventListener(Event.ENTER_FRAME, onEnter);
}
public function onEnter(event:Event)
{
var dx:Number = mouseX - _bullet.x;
var dy:Number = mouseY - _bullet.y;
var angle:Number = Math.atan2(dy,dx) * 180 / Math.PI;
_bullet.rotation = angle;
}
public function shootBullet(event:MouseEvent)
{
init();
}
public function removeBullet(event:MouseEvent)
{
removeChild(_bullet);
}
}
}