O'Reilly logo

jMonkeyEngine 3.0 Cookbook by Rickard Edén

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating an RTS camera AppState object

In this recipe, we'll try to mimic the camera and controls that are common in RTS games. The camera will mostly look down on the scene, and aside from basic movement and rotation of the camera, there will also be automatic scrolling when the mouse reaches the edges of the screen.

Getting ready

We're going to set up the camera and camera handling in this recipe. Loading a scene to make sure the camera works as expected would be helpful.

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 ActionListener interfaces so that we can receive user input from the mouse and keyboard. We'll use these to control the camera ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required