I don't know if your method does minimize the battery usage, but i think it would be better to disable continuous Rendering
by calling Gdx.graphics.setContinuousRendering(false);
in the Applicationlistener
s create or something like this.
By doing this you stop the gameloop from calling your render()
method. It is then only called in the following situations:
- On Input (Keypress, touchdown...)
- On a call of
Gdx.graphics.requestRendering();
- On a call to
Gdx.app.postRunnable()
Read this for more informations.
EDIT:
I have now read your edit. Well "Puzzle game" sounds a bit generally for me. If you are sure, that the user will be staring at a motionless screen for a long time, to find a possible solution, then maybe the non-continuous rendering
is the right way. But if it is (for example) a platformer with some puzzle elements, the user will probably move the whole time and solve the puzzle "on the fly". In this case i would redner normally.
Also you have to think about the other logic, outside of the current view:
Again the example with the platformer: If you have to solve a puzzle to open a door or whatever, behind this door maybe some monsters are waiting for you to come. So if they patrol arround, you have to update their possitions, even if they are outside of the view (behind the door, outside of the building...). In this case again i would not use non-continuous rendering
.
The timer you mentioned, will call render()
, if it is fired. See this for reference.
To run something, without calling render()
you need to run it on another Thread
, so for this use java.util.Timer
instead of libgdx Timer
.
EDIT: As you have now replaced "puzzle game" with "word game" i think i know what you mean.
Normally you only need to render, when an input event is fired. But as much as i understood you want some objects to appear on screen (to make it more interesting than a motionless picture?). For this you need to use a Timer
, i am not sure if libgdx Timer
could do this, if not you can use java.util.Timer
and when a Timer
event gets fired you just call requestRendering()
and in your render update gamelogic and the redraw.