Search code examples
androidlibgdxbox2dlights

Box2d Light consumes too much battery


I'm making a simple game with my friends in Android using libgdx game engine.

We use "conelight" object of box2dlights extension in the game. Our problem is that after putting "conelight" in a game, our app starts to consume too much battery.

Is there a way too prevent this ?

Any help will be appreciated

Thank you


Solution

  • Calculating lights is computational intensive and thus increases energy consumption.

    There are a few things you can check to try to minimize that:

    1. Check if you only create those lights once (for example not in your render method)
    2. Reduce the distance, cone degree and number of rays.
    3. Do you use box2d or do you cast shadows? If not you can get an equal effect with light textures.

    And then it might depend on the android version or how old the phone is.