-
Notifications
You must be signed in to change notification settings - Fork 0
Lighting
With Tiled, lighting is also quite easy to implement!
First you need to enable Lighting on your state with:
enableLights();
And after loading the Tmx map, read its information with:
updateTmxLightInfo();
Then your constructor should be something like this:
Then in your Tiled Map, in the Map Properties, set the ambientLight color to any color you want to, and ambientAlpha to the intensity of the ambient Lighting:
And then in the game you can the the ambient light taking effect:
To create a light point in the game, you create an object, and set its properties:
In the type property, you can put pointLight or coneLight (only those supported by now)
And the other properties:
class = com.mygdx.game.objects.LightObject -> The class that instances the light
color -> The light color
distance -> How far will the light go
intensity -> How strong will the light be
angle (coneLight only) -> wich angle will the light shine to
angleCone (coneLight only) -> the cone opening in degrees.
Remember you can get those light references in the game using its ID:
getTmxRenderer().getInstancedObject(ObjectID); //In the State class
//The object id is the one in the TiledYou can cast it to a LightObject and use the way you want! Maybe attach to a player, or change its color, intensity and distance




