我设置了很长的代码,我知道应该有一个更简单的方法,但我似乎找不到它。我希望敌人每级将速度提高 0.5。我怎样才能做到这一点?
function makeEnemies():void
{
var chance:Number = Math.floor(Math.random() * 150);
if (chance <= + level)
{
tempEnemy = new Enemy();
tempEnemy.speed = 2
//Math.random(); gets a random number from 0.0-1.0
tempEnemy.x = Math.round(Math.random() * 1000);
addChild(tempEnemy);
enemies.push(tempEnemy);
if (level == 2)
{
tempEnemy.speed = 3
}
if (level == 3)
tempEnemy.speed = 4
}
}
}