Applying a sprite-based shadow
The addition of shadows to a game can increase the visual depth and give the game a more appealing appearance. Simply placing a sprite with a shadow texture below an object is a fast and efficient way to handle shadow creation. In this chapter, we will be learning how to do that while keeping the shadow properly aligned with its parent object.
Getting ready...
First, create a new activity class named SpriteShadowActivity
that extends BaseGameActivity
and implements IOnSceneTouchListener
. Next, place a shadow image with a size of 256 x 128 and named shadow.png
into the assets/gfx/
folder. Finally, place a character image of size 128 x 256 and named character.png
into the assets/gfx/
folder.
How to do it...
Follow these steps to build our SpriteShadowActivity
activity class:
Place the following standard AndEngine activity code in our activity class:
@Override public EngineOptions onCreateEngineOptions() { EngineOptions engineOptions = new EngineOptions(true, ...