我为战士和子弹使用阵列
package {
import flash.display.MovieClip;
import flash.events.Event;
public class level extends MovieClip {
var fighters:Array;
var bullets:Array;
public function level() {
trace("level");
addEventListener(Event.ENTER_FRAME, loop);
bullets=new Array();
fighters=new Array();
}
function loop(e:Event) {
if(numChildren<3) {
var f=new fighter();
addChild(f);
// fighter spaWNS RANDOMLY
f.x=Math.random()*stage.stageWidth;
f.y=Math.random()*stage.stageHeight;
f.rotation=Math.random()*360;
fighters.push(f);
}
for(var bcount=bullets.length-1; bcount>=0; bcount--) {
bullets[bcount].update();
if(bullets[bcount].parent==null) {
bullets.splice(bcount,1);
bcount--;
}
}
for(var count=fighters.length-1; count>=0; count--) {
//**** error is here
//**** there is a mismatch in the arguments with the fighter
fighters[count].update();
for(bcount=bullets.length-1; bcount>=0; bcount--) {
if(fighters[count].hitTestObject(bullets[bcount])) {
fighters[count].health--;
removeChild(bullets[bcount]);
bullets.splice(bcount,1);
}
}
if(fighters[count].health<=0) {
removeChild(fighters[count]);
fighters.splice(count,1);
}
}
}
}
}
答案 0 :(得分:0)
错误#1063表示您未传递所需的参数或传递的数量超出预期。可能有关于您没有发布的可能有帮助的错误的其他信息,它很可能看起来像:
ArgumentError:错误#1063:类和函数的参数计数不匹配•。预计1,得到0
检查fighter()对象的update()函数,看看它是否需要参数。