Testing Android controls on libGDX PC application using libGDX remote

When testing our games, sometimes we only need to test the game controls on the Android devices, not all the game, and deploying it on the device is always slower than running it on the PC.

The LibGDX library provides a way to send your Android device input data to through the network, one of the possible uses is to control your libGDX PC application with it.

Here is a demo video using the remote input, made by libGDX team:

(note: magic starts after minute 2)

In the case of Super Flying Thing, we need it when testing and debugging some controls that cannot be tested directly on PC like the TiltController for example (we need device orientation data). Recently, we starting using it also to test and customize other controls like the the ClassicController (despite it has a bit of lag in some cases).

Sadly, my camera is also my android phone so I can't make a video of how we are using it.

One interesting point of this is that we could use multiple android devices (and probably other devices like iPod/iPhone/iPad/others) to create multiple wireless controllers for PC, and that, for example, could be funny if we want to make a local multiplayer game.

Another interesting point is that you could implement your own remote input server to read the device input data sent by the GDX Remote Android Application, so you wouldn't be forced to use libGDX in your server application.

VN:F [1.9.22_1171]
Rating: 4.3/5 (7 votes cast)

Simplifying building bodies and joints with libGDX Box2D - 2

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 
				.circleShape(radius * 0.1f) 
		.position(x, y) 

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.

VN:F [1.9.22_1171]
Rating: 4.2/5 (6 votes cast)

Simplifying building bodies and joints with libGDX Box2D

In almost all of our latest games we are using libGDX as our main game library. As it comes with a wrapper of well known physics library Box2D, we are using it as well.

Some times when creating a Box2D body, you have to initialize a lot of stuff, you have to create a BodyDef and a FixtureDef and then create the Body with the BodyDef, after that create the fixture on the body using the FixtureDef, it could be a bit confuse.

The next code snippet shows an example of that:

	BodyDef bodyDef = new BodyDef();
	FixtureDef fixtureDef = new FixtureDef();

	bodyDef.type = BodyType.StaticBody;
	bodyDef.bullet = false;
	// ... more stuff

	Shape shape = new CircleShape();

	fixtureDef.shape = shape
	fixtureDef.friction = 1f;
	// ... more fixtureDef stuff

	Body body = world.createBody(bodyDef);

To improve this a bit, I have created a BodyBuilder which lets you build Box2D physics bodies in less code lines.

The following code snippet shows an example of using the BodyBuilder:

	Body body = bodyBuilder
			.circleShape(radius * 0.1f)
			.position(x, y)

As you can see, it looks smaller and cleaner. However, it has the limitation (because I was lazy when I did the class) it works for only one fixture def, if you want to build a complex body that will be a problem.

There is also a similar builder for Joints named JointBuilder but it is just started.

The following code snippet shows an example of using the JointBuilder:

	Joint joint = jointBuilder.distanceJoint() 

If you are using libGDX Box2D as well, both classes could be of help despite they are incomplete.

VN:F [1.9.22_1171]
Rating: 4.6/5 (10 votes cast)