Question

I'm looking a minimising battery usage in a game I'm developing, and battery usage is something that's very hard to measure accurately, so I was hoping someone in the know might be able to answer this.

Is it likely to be worth my implementing a system where I don't render when there are no updates to what's displayed on the screen? Something like

updated = false;

for each component
  updated |= component.update();

if (updated)
  render();

This is the kind of thing that's much easier to add at the start, if it'll be worthwhile, than to try to add in at the end if it's required.

If I was rendering through the CPU then I'd definitely say it was worth doing, but through the GPU I'm not so sure. Will in save an insignificant amount of battery compared to things like the screen being on?

edit: A bit of clarification. I'm creating a word game, so a lot of the time the user is going to be staring at a motionless screen looking for words. Depending on the mode the game is being played in, something could happen on the screen that isn't triggered by user input. For example, a new object appearing on the screen every 5 seconds. Rendering 300 frames where nothing happens every 5 seconds seems a real waste and is something I'd like to avoid.

Was it helpful?

Solution

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 Applicationlisteners 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:

  1. On Input (Keypress, touchdown...)
  2. On a call of Gdx.graphics.requestRendering();
  3. 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 Timerevent gets fired you just call requestRendering() and in your render update gamelogic and the redraw.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top