Book Image

Libgdx Cross-platform Game Development Cookbook

Book Image

Libgdx Cross-platform Game Development Cookbook

Overview of this book

Table of Contents (20 chapters)
Libgdx Cross-platform Game Development Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

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 file as explained in Chapter 1, Diving into Libgdx.

To the core and the Android project, add the following:

compile "com.badlogicgames.box2dlights:box2dlights:1.2" 

To the web project, add the following:

compile "com.badlogicgames.box2dlights:box2dlights...