我面临着使用链形的新问题。两个链状体之间的碰撞并没有像正常体那样发生。所以这是正常行为还是我为此做错了什么?
以下是用于此目的的代码。
ChainShape mChainShape = new ChainShape();
Vector2[] mVector2 = new Vector2[lineList.size()];
for (int i = 0; i < lineList.size(); i++) {
mVector2[i] = new Vector2(lineList.get(i).getX1()
/ PhysicsConstants.PIXEL_TO_METER_RATIO_DEFAULT,
lineList.get(i).getY1()
/ PhysicsConstants.PIXEL_TO_METER_RATIO_DEFAULT);
}
mChainShape.createChain(mVector2);
FixtureDef mFixtureDef = new FixtureDef();
Body mChainBody;
BodyDef mBodyDef = new BodyDef();
mBodyDef.type = BodyType.DynamicBody;
mChainBody = mPhysicsWorld.createBody(mBodyDef);
mFixtureDef.shape = mChainShape;
mFixtureDef.density = 1f;
mFixtureDef.friction = 0.5f;
mFixtureDef.restitution = 0.5f;
mChainBody.createFixture(mFixtureDef);
mChainShape.dispose();
如果我想根据触摸坐标创建身体,那么这件事可能吗?
请在这方面给予任何指导。