这部分编码用于塔防游戏中的炮塔。截至目前,它没有出现,如果有人看到错误帮助将不胜感激。
package
{
import flash.display.MovieClip;
import flash.events.*;
public class Turret extends MovieClip
{
private var _root:MovieClip;
public function Turret()
{
this.addEventListener(Event.ADDED, beginClass);
this.addEventListener(Event.ENTER_FRAME, eFrameEvents);
}
private function beginClass(e:Event):void
**//Where I make the turret itself**
{
_root = MovieClip(root);
this.graphics.beginFill(0xFFD700);
this.graphics.drawCircle(0,0,12.5);
this.graphics.endFill();
this.graphics.beginFill(0xFFD700);
this.graphics.drawRect(-2.5, 0, 5, 20);
this.graphics.endFill();
}
private function eFrameEvents(e:Event):void
{
if (_root.gameOver)
{
this.removeEventListener(Event.ENTER_FRAME, eFrameEvents);
MovieClip(this.parent).removeChild(this);
}
}
}
}