Libgdx tutorial beginner Part 10 – Android Black Screen

As I was thinking on adding new features, I realised that when I press the menu button on android the app went into the background. After that if I resumed the map and bob were not being rendered.

First I thought it is the textures that are not being loaded, unfortunately it wasn’t that. After spending 2 hours I realised that the position of Bob after resume is NaN both for x and y. In case you haven’t heard of NaN in math, it’s an undefined number, like the square root of a negative number. How does this relate to this case? Well after resuming the app the first delta received is 0.0, that shouldn’t be a problem but if you have a value and you are trying to divide it by delta then we have a huge problem(I’m looking at you Mario). That means dividing a value by 0.0 in androids java will produce a NaN.

What I did for now, I skip updating bob in map when delta is 0.0

Recent Posts