2014-08-29 64 views
0

我试图编写包含玩家精灵和障碍物的简单游戏。 我已经用重力实现了一个物理世界。我希望当玩家精灵掉落时,它将会靠近它从落下的障碍物上,但是在重力的作用下,精灵落在对角线上而不是直线下降。在引擎中引发问题android

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)); 

} 

current state and wanted state

回答

0

你可以尝试设置海量数据,你的身体:

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

mBody.setMassData(mass);