0

我尝试编写包含玩家精灵和障碍物的简单游戏。我已经实现了一个带有重力的物理世界。我希望当玩家精灵落下时,它会靠近它落下的障碍物,但在重力作用下,精灵会以对角线方向而不是直线下降。

mPhysicsWorld = new PhysicsWorld(new Vector2(0, SensorManager.GRAVITY_EARTH), false);
...

public Player(PhysicsWorld world, final float pX, final float pY, final TiledTextureRegion pTextureRegion,
        final VertexBufferObjectManager pVertexBufferObjectManager)
{
    super(pX, pY, pTextureRegion, pVertexBufferObjectManager);

    mPlayerDeff = PhysicsFactory.createFixtureDef(0, 0, 0);

    mVertexBuffer = pVertexBufferObjectManager;
    mBoardManager = BoardManager.getInstance();
    mDirection = DIRECTION_RIGHT;

    mWorld = world;

    mBody = PhysicsFactory.createBoxBody(mWorld, this, BodyType.DynamicBody, mPlayerDeff);
    mWorld.registerPhysicsConnector(new PhysicsConnector(this, mBody, true, false));

}

当前状态和通缉状态

4

1 回答 1

0

您可以尝试为您的身体设置海量数据:

MassData mass = new MassData();
mass.mass = 10; // in kilograms

mBody.setMassData(mass);
于 2014-09-01T06:41:40.437 回答