【发布时间】:2014-05-20 10:50:04
【问题描述】:
所以我有一堆火球,我想知道如何移动这些物品来创建一个类似手套的游戏。我已经创建了阵列,里面装满了火球,但我似乎无法让它们移动。这是我创建的数组的样子:
for (var i:Number = 0; i < fireballs; i++) {
var mcFireball :fireball = new fireball();
this.addChild(mcFireball);
mcFireball.x = Math.floor((Math.random() * location) + 100);
mcFireball.y = Math.floor((Math.random() * location) + 100);
mcFireball.scaleX = .5;
mcFireball.scaleY = .5;
array.push(mcFireball);
}
这就是我尝试移动它们的方式:
for (var i :Number = 0; i < fireballs; i++) {
if (array[i] == null) {
trace("Error here");
return;
}
trace(array[i]);
var mcFireball :fireball = array[i];
mcFireball.moveEnemy();
}
这就是我的 moveEnemy() 的样子:
public function moveEnemy():void
{
if ((this.x + this.width > this.stage.stageWidth) || (this.x - this.width <= 0))
_nEnemyMovementSpeed *= -1;
this.x += _nEnemyMovementSpeed;
}
我确定错误在函数的范围内,但我不确定我需要做什么才能使它们正常工作
My error is that moveEnemy() isn't a function
【问题讨论】:
标签: arrays actionscript-3 flash actionscript game-physics