Applying a controller to the display
Depending on the type of game we are creating, there are many possible solutions for player interactivity. AndEngine includes two separate classes, one of which simulates a directional control pad called a DigitalOnScreenControl
, the other which simulates a joystick called an AnalogOnScreenControl
. This topic is going to introduce AndEngine's AnalogOnScreenControl
class, but working with this class will give us enough info to use either controller.
Getting started...
This recipe requires two separate assets which will act as the base of the controller and the knob of the controller. Before moving on to the How to do it... section, please include an image called controller_base.png
and controller_knob.png
to the assets/gfx
folder in a project of your choice. The images may look something like the following figure, with the base being 128 x 128 pixels and the knob being 64 x 64 pixels:
How to do it…
Once we've got the two necessary assets in place for our controller...