Game Development Reference
In-Depth Information
How to do it...
To create an RTS camera AppState object, perform the following steps:
1. We start by creating a class that implements the AnalogListener and Ac-
tionListener interfaces so that we can receive user input from the mouse and
keyboard. We'll use these to control the camera as follows:
public class RTSCameraAppState extends
AbstractAppState implements AnalogListener,
ActionListener{
2. Next, we'll define what controls we'll handle. Using an enum will keep things tidy,
so type the following code snippet:
public enum InputMapping{
MoveLeft, MoveRight, MoveUp, MoveDown,
RotateLeft, RotateRight;
}
The following screenshot shows you the difference between the camera's position
above the ground (half circle) and the camera's focus point (at the center):
Search WWH ::




Custom Search