Andengine的Box2d - 附着儿童身体 - 是否可能

时间:2015-03-09 02:13:23

标签: android box2d andengine

我对Andengine Box2d扩展有问题。

我有2个矩形: base fuelStation

fuelStation 是基础的孩子。当我使用setTransform方法旋转 base 时, fuelStation 精灵也在旋转,但是身体保持在同一位置。

Red - base, Cyan - child

base = new Rectangle(CAMERA_WIDTH / 2, CAMERA_HEIGHT / 2 - 200, 200, 200, vbom);
fuelStation = new Rectangle(base.getWidth() / 2, 0, 500, 10, vbom);

this.attachChild(base);
base.attachChild(fuelStation);

final FixtureDef objectFixtureDef1 = PhysicsFactory.createFixtureDef(1, 0.0f, 0.5f);
final FixtureDef objectFixtureDef2 = PhysicsFactory.createFixtureDef(1, 0.0f, 0.5f);

baseBody = PhysicsFactory.createBoxBody(physicsWorld, base, BodyType.StaticBody, objectFixtureDef1);
baseBody.setUserData("base");

fuelStationBody = PhysicsFactory.createBoxBody(physicsWorld, fuelStation, BodyType.KinematicBody, objectFixtureDef2);
fuelStationBody.setUserData("station");

physicsWorld.registerPhysicsConnector(new PhysicsConnector(base, baseBody, true, true));
// physicsWorld.registerPhysicsConnector(new PhysicsConnector(fuelStation, fuelStationBody,
// true, true));

当我从最后一行删除评论时 - 精灵位置发生变化但仍无法正常工作(身体静止不动)。

如何正确连接这2个身体?

0 个答案:

没有答案