0

我正在尝试制作游戏,但 flash 给了我这个警告代码:

场景 1,图层“roachLevel”,第 1 帧,第 98 行警告:3596:重复变量定义。

每次我删除“重复变量”都会阻碍我的游戏,游戏将无法正常运行。这是发生警告的代码:

function moveEnemies():void
{
var tempEnemy:MovieClip;


for (var i:int =enemies.length-1; i>=0; i--)
{
     var tempEnemy=enemies[i];
if (tempEnemy.dead) 
{
    score++;
    score++;
    roachLevel.score_txt.text = String(score);
    enemies.splice(i,1);
} 



     else // Enemy is still alive and moving across the screen
    {
        //rotate the enemy between 10-5 degrees
        tempEnemy.rotation += (Math.round(Math.random()*.4));
        //Find the rotation and move the x position that direction
        tempEnemy.x -=  (Math.sin((Math.PI/180)*tempEnemy.rotation))*tempEnemy.speed;
        tempEnemy.y +=  (Math.cos((Math.PI/180)*tempEnemy.rotation))*tempEnemy.speed;
        if (tempEnemy.x < 10)
        {
            tempEnemy.x = 11;
        }
        if (tempEnemy.x > stage.stageWidth - offset)
        {
             tempEnemy.x = stage.stageWidth - offset;
        }
        if (tempEnemy.y > stage.stageHeight)
        {
            removeEnemy(i);

            lives--;
            roachLevel.lives_txt.text = String(lives);
        }
    }
}
}
4

0 回答 0