O'Reilly logo

Libgdx Cross-platform Game Development Cookbook by Alberto Cejas Sánchez, David Saltares Márquez

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Dynamic 2D lighting with Box2DLights

Lights have a huge influence on the final appearance of your game as they are always present in a person's day-to-day life. They enrich the visual interaction that the player receives by adding some dynamism to the scene and, therefore, catch his or her attention.

Box2DLights was created by Kalle Hameleinen relying on Box2D for raycasting, so it can understand the geometry and OpenGL ES 2.0 or above for rendering through shaders.

In this recipe, we will explore the library, explaining how to endow your game with a significant visual improvement.

Getting ready

The code for this recipe is concentrated on one single file named Box2DLightsSample.java. Make sure that you add the following dependences to the build.gradle ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required