libGDX utils package - general quality and impressions

Not sure why I did not see it before, but I finally noticed all of the utility classes packed into com.badlogic.gdx.utils as well as the math and physics packages. I was curious if people have used these classes and what their impressions were, specifically around the collection classes.

I could see myself switching over to the libgdx collections, specifically for maps and sets. I know it’s good to avoid premature optimization, but if there are ready-made classes in a library I am already using, then why not use them?

I know the answer to my question is (1) if what you’re doing works well enough stick with that and (2) try it for yourself and see; but I was curious what other people’s experience has been.

They can provide some significant (i.e. measurable) performance improvements on low-end devices, where things like allocations (e.g. for-each loop) or auto-boxing can be very detrimental.

For example, LibGDX’s StringBuilder.append(int) doesn’t lead to any allocations, which makes it especially attractive for displaying integer text on Android (i.e. FPS, player score).

If you are building a 3rd party API, it would be poor practice to use, say, LibGDX’s collections instead of the standard collections. But if you are building a game, or a LibGDX-specific extension, or working on internal code that needs to be highly optimized, then it makes much more sense to use LibGDX’s collections.

Even the Android docs recommend against getters and setters, which makes the LibGDX utilities desirable:
http://developer.android.com/training/articles/perf-tips.html

Aside from the collections, the vector/matrix and math utilities are really excellent. The vecmath is in many areas accelerated with native code. And the MathUtils sin/cos/etc are usually a little faster than java.lang.Math, at the expense of precision.

And then there is a whole slew of other utilities, like reflection (that works correctly with GWT), Pools for re-using temporary objects, fast and lightweight JSON and XML parsing, etc.

TL;DR - the GDX utils are the best thing since sliced bread, so definitely use them in your games.

Thanks, I am using it for my game rather than a third party library so i will give them a look. i think i have finally gotten past the ‘i will implement everything form scratch as a learning experience" and actually focus on making a stinkin’ game.

Let us implement everything from scratch for you :slight_smile:

Yar! That would be a nice libGdx slogan.

Ew that sounds less OSS and more like expensive enterprise $$$ service ;D