【发布时间】:2018-12-08 09:13:13
【问题描述】:
我正在关注http://markbennison.com/actionscript/as3-space-shooter/2-coding-projectiles/
上的 Action Script 3 教程我在第 2 部分编码弹丸我不知道为什么我按播放时总是说错误
“ArgumentError:错误 #2025:提供的 DisplayObject 必须是调用者的子对象。”
这是我尝试在按下空格键时发射子弹的确切代码,还有更多但不知道如何修复参数错误。
function addBullet(startX, startY): void {
//declare an object instance from the bullet Class
var b: Bullet = new Bullet();
//set the new bullet's x-y coordinates
b.x = startX;
b.y = startY;
//add the new bullet to the stage
stage.addChild(b);
//store the object in an array
bullets_arr.push(b);
}
函数 moveBullet(): 无效 {
//loop through all instances of the bullet
//loop from '0' to 'number_of_bullets'
for (var i: int = 0; i < bullets_arr.length; i++) {
//move the bullet
bullets_arr[i].x += bulletSpeed;
//if the bullet flies off the screen, remove it
if (bullets_arr[i].x > stage.stageWidth) {
//remove the bullet from the stage
stage.removeChild(bullets_arr[i]);
//remove the bullet from the array
bullets_arr.removeAt(i);
}
}
}
有人可以给我一些改变什么的提示吗?
【问题讨论】:
-
您的问题解决了吗?
标签: javascript actionscript-3 flash actionscript flash-cs6