Time for action — using lights and shadow casters
Lighting and shadow engines are normally used in 3D games to add realism to the scene, but rarely they are also used in 2D games to improve visuals as well.
1. On the
LevelLights
layer, create aLight
object calledWhiteLight
and accept the default image it comes with. Set itsShadow filter
property toWebBlack
and itsShadow opacity
to60%
.2. Place the object in your layout where you would like light to come in from:
3. Now on the
ShadowCasters
layer, create aSprite
calledShadowMask
and fill it withBlack
. Give this object the Collisions modeNone
and check the box for Destroy on Startup before adding theShadowcaster
behavior to it and setting Shadow depth to1
and the shadowCollision Mask
toBounding Box
.4. Now switch over to the
Game
events, and in theStartup
group add sub-eventsFor each Ground
object andFor each CrateBox
object to the mainStart of layout
event.5. For the first sub-event, add actions to create the
ShadowMask
object...