プレイヤーに弾丸を発生させる敵クラスがあります。
private function fireBullet()
{
if(isFiring)
{
fire();
}
}
public function fire():void
{
var bullet:Bullet = new Bullet(x, y, rotation);
stage.addChild(bullet);
}
そして弾丸クラスでは:
package {
import flash.display.MovieClip;
import flash.events.Event;
public class Bullet extends MovieClip {
private var _root:MovieClip;
private var isVanished:Boolean = false;
public function Bullet(x:int, y:int, rotation:Number)
{
this.x = x;
this.y = y;
this.rotation = rotation;
_root = MovieClip(root);
addEventListener(Event.ENTER_FRAME, loop);
}
private function loop (event:Event):void
{
if(this.hitTestObject(_root.assassin.hitbox))
{
_root.hitPoints -= 30;
}
else
{
y-=Math.cos(rotation/-180*Math.PI)*(15);
x-=Math.sin(rotation/-180*Math.PI)*(15);
}
if(this.x < 0 || this.x > _root.stageWidth || this.y > _root.stageWidth || this.y < 0)
{
removeChild(this);
removeEventListener(Event.ENTER_FRAME, loop);
}
}
}
}
しかし、ゲームを開始すると、23 行目で 1009 エラーが発生し、弾丸も動かないため、ゲームが急速に遅くなります。
また、1063 エラーが発生します。3 を期待していますが、0 です。
ArgumentError: Error #1063: Argumentblabla for Bullet(). Expected 3 but 0 were shown. ((translated)) at flash.display::Sprite/constructChildren() at flash.display::Sprite() at flash.display::MovieClip() at Main()[C:\Venture Inc\Main.as:189]
メインはこんな感じ
//Constructor
public function Main()
{
addChild(container_staff);
addChild(container_wall);
etc etc etc