BodyBuilder, which I commented on a previous post, has been updated to work with multiple fixtures, keeping simplicity.

Internally, it uses a FixtureDef builder named FixtureDefBuilder which lets you specify a fixture definition for each fixture.

Here is an example of how it looks now it supports multiple fixture definitions:

Body body = bodyBuilder 
		.fixture(bodyBuilder.fixtureDefBuilder() 
				.circleShape(radius * 0.1f) 
				.categoryBits(CategoryBits.MiniPlanetCategoryBits) 
				.restitution(0f)) 
		.fixture(bodyBuilder.fixtureDefBuilder() 
				.circleShape(radius) 
				.categoryBits(CategoryBits.AllCategoryBits) 
				.sensor()) 
		.position(x, y) 
		.mass(1f) 
		.type(BodyType.StaticBody) 
		.userData(e) 
		.build();

The previous example shows how to declare two fixtures for a Body, one of them is a sensor. For you to know, I am using that code in Super Flying Thing to declare the destination planet (that’s the name for now), the sensor is to detect when the ship is near to trigger an event and then attach it to the planet by creating a Box2D Joint.

If you are a game programmer, it could be useful to maintain your code clean and simple.