我有一个小问题。 昨晚我正在寻找替代这个课程的方法,但我没有找到任何东西 在旧版本的andengine教程中,他们使用“PhysicsFactory.class”来创建fixtureDef。 在最近的一个例子中,我看到了类似的东西
FixtureDef ballShapeDef = new FixtureDef();
ballShapeDef.shape = circle;
ballShapeDef.density = 1.0f;
ballShapeDef.friction = 0.2f;
ballShapeDef.restitution = 0.8f;
ballBody.createFixture(ballShapeDef);
但是我不知道physicsFactory和上面的代码是否用不同的方式表示相同的东西,所以现在我有点困惑。
有人可以帮忙吗?答案 0 :(得分:0)
来自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?