【发布时间】:2014-10-31 01:31:56
【问题描述】:
我想添加两个敌人一个数组进行循环,这是我的代码 全球时间++; // 生成敌人 if (global_time % 40 == 0) { 敌人 = 新敌人(); 敌人.x = 40 + Math.random() * 400; 敌人.y = 0; addChild(敌人); 军队.push(敌人); System.gc();
enemy2 = new Enemy2();
enemy2.x = 40 + Math.random() * 400;
enemy2.y = 0;
addChild(enemy2);
army.push(enemy2);
}
for (var k:int = army.length - 1; k >= 0; k--) {
enemy = army[k];
enemy2 = army[k]
// update all enemies
enemy.update();
enemy2.update2();
// if its out of bound, remove from stage
if (enemy.y < 0) {
army.splice(k, 1);
enemy.parent.removeChild(enemy);
continue;
System.gc();
}
//* enemy2
if (enemy2.y < 0) {
army.splice(k, 1);
enemy2.parent.removeChild(enemy2);
continue;
System.gc();
}
}
当我运行此程序时出现错误“无法将 Enemy2@501f5e1 转换为 Enemy”。请帮忙
【问题讨论】:
-
没有看到完整的代码/源代码很难判断,但是,此错误可能表明 SWF 中的 ActionScript 无效或文件已损坏。是您的任何错误 - 1034 Type Coercion failed: cannot convert %a to %t.或 1050 无法将 %o 转换为原语。 ?
标签: actionscript-3 flash