【问题标题】:AndEngine Box2D forces to move a falling characterAndEngine Box2D 强制移动下落的角色
【发布时间】:2011-12-12 17:43:05
【问题描述】:

我正在开发一款横向卷轴游戏,例如超级马里奥。我正在尝试使用setLinearVelocity() 移动角色,但这似乎无法正常工作。当角色摔倒然后开始移动时,他不会继续摔倒,只会移动。

这是一个代码sn-p:

Sprite backward = new Sprite( -50, CAMERA_HEIGHT - 170, backwardr){
    @Override
    public boolean onAreaTouched(TouchEvent pEvent, float pX, float pY){
        if(!pEvent.isActionUp()){
            charactersprite.getTextureRegion().setFlippedHorizontal(true);
            body.setLinearVelocity(new Vector2(3,0)); // There's the problem

        }else{
            body.setLinearVelocity(new Vector2(0,0)); // Don't look at there
        }
        return false;
    }
};

谁能帮帮我?

【问题讨论】:

  • ...我看不出任何问题。你在问什么?你可能想澄清一下。
  • 我在问如何移动角色? (我尝试使用 setLinearVelocity(...); 移动,但它不能正常工作,因为当角色跌倒并开始移动时,他不会跌倒,而只会移动。
  • 我已经为您更新了您的问题。请检查是否正确说明。这是您通常应该明确指出的信息。
  • 我编辑了它。谢谢!请帮忙!
  • 我不工作。该功能不存在。请帮帮我!

标签: box2d physics andengine


【解决方案1】:

我修复了它:

Sprite backward = new Sprite( -50, CAMERA_HEIGHT - 170, backwardr){
    @Override
    public boolean onAreaTouched(TouchEvent pEvent, float pX, float pY){
    if(!pEvent.isActionUp()){
        charactersprite.getTextureRegion().setFlippedHorizontal(true);
        body.setLinearVelocity(new Vector2(3,body.getLinearVelocity.y)); // There's the problem

    }else{
        body.setLinearVelocity(new Vector2(0,getLinearVelocity.y)); // Don't look at there
    }
    return false;
}
};

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多