2014-12-23 43 views
0

我有一個小問題。 昨晚我正在尋找一種方法來替換這個類,但我沒有找到任何東西 在舊版本的andengine教程中,他們使用「PhysicsFactory.class」來創建fixtureDef。 在最近的一個例子我見過類似的東西什麼類代替andengine中的物理工廠?

FixtureDef ballShapeDef = new FixtureDef(); 
ballShapeDef.shape = circle; 
ballShapeDef.density = 1.0f; 
ballShapeDef.friction = 0.2f; 
ballShapeDef.restitution = 0.8f; 
ballBody.createFixture(ballShapeDef); 

但我不「知道,如果上述physicsFactory這個代碼的含義是用相同的事情,但以不同的方式,所以現在我'有點困惑。

public static FixtureDef createFixtureDef(final float pDensity, final float pElasticity, final float pFriction) { 
    return PhysicsFactory.createFixtureDef(pDensity, pElasticity, pFriction, false); 
} 

public static FixtureDef createFixtureDef(final float pDensity, final float pElasticity, final float pFriction, final boolean pSensor) { 
    final FixtureDef fixtureDef = new FixtureDef(); 
    fixtureDef.density = pDensity; 
    fixtureDef.restitution = pElasticity; 
    fixtureDef.friction = pFriction; 
    fixtureDef.isSensor = pSensor; 
    return fixtureDef; 
} 

public static FixtureDef createFixtureDef(final float pDensity, final float pElasticity, final float pFriction, final boolean pSensor, final short pCategoryBits, final short pMaskBits, final short pGroupIndex) { 
    final FixtureDef fixtureDef = new FixtureDef(); 
    fixtureDef.density = pDensity; 
    fixtureDef.restitution = pElasticity; 
    fixtureDef.friction = pFriction; 
    fixtureDef.isSensor = pSensor; 
    final Filter filter = fixtureDef.filter; 
    filter.categoryBits = pCategoryBits; 
    filter.maskBits = pMaskBits; 
    filter.groupIndex = pGroupIndex; 
    return fixtureDef; 
} 

它看起來一樣的東西,但爲什麼:

有人可以從PhysicsFactory類的源代碼,幫助

+0

我也困惑。你真的在找什麼? – sankar

+0

我問我fixtureDef是否與上面這個參數意味着什麼,並且做的事情與他們使用physicsFactor創建boxbody的時候一樣? – litv

回答

0

?你不使用PhysicsFactory嗎?

+0

你是對的,我不知道爲什麼不這樣做,謝謝你的幫助我會這樣做和聖誕快樂 – litv

+0

@litv接受答案,如果它幫助,TY。 – ranifisch