For 2D static lighting, we essentially have two options. The first is to simply add the lighting as we draw the backgrounds and sprites. This reduces it to a purely graphics artist's issue. This is what the official AndEngine examples use as well, such as those we looked at in an earlier chapter, specifically TMXTiledMapExample
and AutoParallaxBackgroundExample
.
In the preceding screenshot of TMXTiledMapExample
, we can clearly see how static lighting is accomplished by drawing the shadows, in particular around the sign and the cactus. The stone edges also have a bit of shadow to indicate that they rise above the ground somewhat.
Meanwhile, the character sprite has a basic round shadow underneath it, even though this is technically incorrect. This is because the shadows in the scene distinctly indicate that the light (the sun) is located in the bottom-left corner, and there should be a shadow expanding from the character in the same direction and same ratio of length as for...