1
votes

I just noticed that when I turn off my screen on my mobile device and turn it on again some graphics resize or disappear. My game is coded towards 800x480 resolution and my HTC Desire HD doesn't have this problem (it has a 800x480 resolution). However, when tested on my HTC One or a Samsung Galaxy S3 the graphics scale or behave weird.

The only thing those objects who behave weird have in common are that they rotate every frame. Stationary objects don't seem to be affected at all.

I have stars who rotates and scales up/down every frame and I have a moving block who goes left/right or up/down. The moving block seems to ignore collision when the screen is restarted and disappears to places he should not be able to reach.

Any ideas?

Thanks in advance.

1
Post your image rotator code if possible.Papasmile
setScale(getScale() + 0.005f * Gdx.graphics.getDeltaTime()* Assets.FPS); setRotation(getRotation() - 0.5f * Gdx.graphics.getDeltaTime()* Assets.FPS);Nine Magics

1 Answers

1
votes

When you turn off the screen, rendering is paused (i.e. no calls to render() are made). When you resume, Gdx.graphics.getDeltaTime() will be very large as the last frame was rendered at least some seconds ago. So the delta time values that are normally in the order of 0.0166 (60 FPS) will now be in the order of a 100 times greater.

If you are using this delta to take a physics simulation / collision check step, that will go beserk because it's way too large. Rotation shouldn't be a real problem, but scaling will also go out the roof.

A simple way to avoid this is to put in something like

if (delta > 0.1f)
    delta = 0.0166f

to avoid taking really large steps.