玩家/角色在2级平台游戏上滑落

时间:2017-03-28 16:12:20

标签: actionscript-3

所以我创建了一个平台游戏,它有2个级别。等级1顺利且完美但是当我进入等级2(在第4帧中)时,玩家/角色突然滑下。我在第1级使用的字符仍然是我在第2级使用的字符。我检查了实例名称,它是正确的,我也重命名了函数名称。它也没有任何编译器错误/输出错误,这就是为什么我很难弄清楚为什么我的播放器会这样做。这是我的代码:

function charMove1()
{
    player_mc.y+=gravity;
    if(leftkeyPressed)
    {
        player_mc.x-=xSpeed;
        player_mc.gotoAndStop(2);
        player_mc.gotoAndStop(1);
    }
    if(leftkeyPressed && leftwallBumping)
    {
        player_mc.x+=xSpeed;
    }
    if(rightkeyPressed)
    {
        player_mc.x+=xSpeed;
        player_mc.gotoAndStop(1);
        player_mc.gotoAndStop(1);
    }
    if(rightkeyPressed && rightwallBumping)
    {
        player_mc.x-=xSpeed;
    }
    if(downwallBumping)
    {
        player_mc.y-=gravity;
    }
    if(upwallBumping)
    {
        player_mc.y+=gravity;
    }
    //set condition for moving the background, player stays at same position with this code
    if(rightkeyPressed && player_mc.x>stage.stageWidth/2+50)
    {
        background1_mc.x-=backgroundSpeed;
        player_mc.x-=xSpeed;
    }
    if(leftkeyPressed && player_mc.x<stage.stageWidth/2-50)
    {
        background1_mc.x+=backgroundSpeed;
        player_mc.x+=xSpeed;
    }
}

0 个答案:

没有答案