Android 如何跳跃和动画的马里奥游戏角色一样的身体?

Android 如何跳跃和动画的马里奥游戏角色一样的身体?,android,andengine,Android,Andengine,我是《安德林》的新手,我正在开发像《马里奥》这样的简单游戏,所以我想以一种合适的方式跳跃和移动这个角色 请给我一些想法,我使用的速度和冲动,但这是不正常的工作 AndEngineesExamples项目包含几个与您的应用程序类似的示例游戏。 在深入研究代码之前,您可以先下载APK并试用 以下是我是如何做到的(我的播放器类接口): 然后,我创建了向左、向右、跳跃等按钮。 在AreaTouched事件中,对于动作向下,我执行player.jump()。 对于动作,我做player.stopJump(

我是《安德林》的新手,我正在开发像《马里奥》这样的简单游戏,所以我想以一种合适的方式跳跃和移动这个角色


请给我一些想法,我使用的速度和冲动,但这是不正常的工作

AndEngineesExamples项目包含几个与您的应用程序类似的示例游戏。 在深入研究代码之前,您可以先下载APK并试用

以下是我是如何做到的(我的播放器类接口):

然后,我创建了向左、向右、跳跃等按钮。 在AreaTouched事件中,对于动作向下,我执行
player.jump()
。 对于动作,我做
player.stopJump()

“向左移动”和“向右移动”按钮的代码基本相同。

你能发布你拥有的atm吗?我不知道atm是什么意思。“我是新来的”和“我想要”不是这里提问的正确方式,发布代码很有帮助。代表“此刻”,如果你是新开发的马里奥式游戏,那么你必须看看这个教程系列,你肯定会有所收获。
public void moveLeft() {
    Vector2 velocity = Vector2Pool.obtain(-speed, body.getLinearVelocity().y);
    body.setLinearVelocity(velocity);                   
    Vector2Pool.recycle(velocity);

    int offset = isInjured ? 4 : 0;     
    if (!isAnimationRunning()) {
        setCurrentTileIndex(2 + offset);
        animate(new long[]{200, 200}, 2 + offset, 3 + offset, 1, animationListener);    
    }
}

public void moveRight() {
    Vector2 velocity = Vector2Pool.obtain(speed, body.getLinearVelocity().y);
    body.setLinearVelocity(velocity);               
    Vector2Pool.recycle(velocity);  

    int offset = isInjured ? 4 : 0; 
    if (!isAnimationRunning()) {
        setCurrentTileIndex(0 + offset);
        animate(new long[]{200, 200}, 0 + offset, 1 + offset, 1, animationListener);        
    }
}

public void stop() {
    Vector2 velocity = Vector2Pool.obtain(0, body.getLinearVelocity().y);
    body.setLinearVelocity(velocity);                   
    Vector2Pool.recycle(velocity);

    stopAnimation();

    int offset = isInjured ? 4 : 0;
    if(getCurrentTileIndex() % 4 > 1 ) 
        setCurrentTileIndex(2 + offset);
    else 
        setCurrentTileIndex(0 + offset);
}

public void stopJump() {
    if(jumpsLeft > 0) {
        Vector2 velocity = Vector2Pool.obtain(body.getLinearVelocity().x, body.getLinearVelocity().y / 5);
        body.setLinearVelocity(velocity);                   
        Vector2Pool.recycle(velocity);  
    }
}

public void jump() {
    if(jumpsLeft > 0) {
        Vector2 impulse = Vector2Pool.obtain(0, body.getMass() * -12);
        body.applyLinearImpulse(impulse, body.getWorldCenter());                
        Vector2Pool.recycle(impulse);   
        jumpsLeft--;
    }
}