Pocket Fan Sound

I’m working on a new sound clip for Pocket Fan. I’ve gotten some complaints that there is a small, but noticeable, “hitch” in the sound. Some have also said that it sounds more like a car than a fan.

I agree with both of these sentiments, so I am working on a new sound clip. Just in case anybody has fallen in love with the original sound, I plan to allow users to choose which sound plays when they turn on the fan.

What I need to do:

1. Find a new fan sound clip. Now that Pocket Fan has made a bit of money, I can justify buying a quality recording.

2. Edit the clip to eliminate any audible skips during looping.

Hopefully I will have this done in a week. Stay tuned.

BitmapFont can Increase Your LibGDX Load Time

I noticed that my game was making a lot of calls to StringTokenizer and other String-related classes during significant portions of its load time. My game spent nearly 50% of its load time chugging away at Strings somewhere. This perplexed me for weeks until I noticed some calls to BitmapFont. I knew that BitmapFont had some expensive operations but I didn’t realize that just creating a new instance is very expensive.

I went about consolidating all the BitmapFont instances into one shared instance in the main Game class. I then passed the reference to this instance into the constructors for whatever classes needed to write text to the screen. Going from 4 instances of BitmapFont to just 1 shaved about 4 seconds off the load time. That’s a huge improvement when my game used to take 8 seconds to load on my Evo 4G.

So if method profiling yields several groups of StringTokenizer calls lasting around 1-2 seconds during your game’s loading phase, check if you are using more than one instance of BitmapFont. If all of your text uses the same font style and size, try using one shared instance.

Using Partial WakeLock in libGDX

A reader asking how they could keep sound running in a libGDX Android project when the screen turns off. I don’t use libGDX in Pocket Fan, but I do use a Wake Lock to keep the sound running while the screen is off, so maybe we can do something similar with libGDX. Read more

Unexpected Uses for Pocket Fan

I envisioned Pocket Fan to be a novelty app. What else would you call an app that displayed an animated fan? It certainly wasn’t supposed to be useful. My perception changed when I got this comment on the Android Market:

Can’t sleep without the sound of a fan. This is almost perfect for power outages. Just needs to stay open and not black screen after 1 minute.

When I first read that comment, I thought to myself “He can just set his screen to never time out…” and went back to work on my game. Then I saw a post on reddit entitled “I can’t sleep unless you’re near me…”. It was just a picture of a box fan, but it all clicked for me then. Pocket Fan could be used as a sound machine or noise generator.  Read more

Catching libgdx Exceptions in Eclipse

For those of you that actually know what you’re doing in Eclipse, you can skip this post. For the rest of us, I wanted to share a quick tip for debugging libgdx in Eclipse.

Make sure to set the debugger to break on GdxRuntimeException or any other libgdx exceptions you want to inspect. This Stack Overflow post shows how.

If you don’t set the debugger to catch these exceptions, you’ll likely find that it breaks execution in the OpenGL thread, which is generally not very helpful, because the code that threw the original exception is in your game thread.