I would like some clarifications on the AndEngine revoluteJoint example. In the code below the connectionLine has x1,y1 & x2,y2 the same value. So this should create a single point. Why is this done?
final Line connectionLine = new Line(anchorFaceX + spriteWidth / 2, anchorFaceY +
spriteHeight / 2, anchorFaceX + spriteWidth / 2, anchorFaceY + spriteHeight / 2,
this.getVertexBufferObjectManager());
What does the setPosition do below? Does it transform the line so that it appears to rotate?
this.mPhysicsWorld.registerPhysicsConnector(new PhysicsConnector(anchorFace,
anchorBody, true, true){
@Override
public void onUpdate(final float pSecondsElapsed) {
super.onUpdate(pSecondsElapsed);
final Vector2 movingBodyWorldCenter = movingBody.getWorldCenter();
connectionLine.setPosition(connectionLine.getX1(), connectionLine.getY1(),
movingBodyWorldCenter.x * PhysicsConstants.PIXEL_TO_METER_RATIO_DEFAULT,
movingBodyWorldCenter.y * PhysicsConstants.PIXEL_TO_METER_RATIO_DEFAULT);
}
});
I would appreciate any clarification. I need to create a line that is rigidly connected to bodies as they move.
I was able to connect the bodies with lines which stay connected as the bodies move as follows