Time for action – call me maybe?

In the CubeChaser class, the added CubeChaserControl classes mark individual cubes, and the AppState object identifies and transforms them when certain conditions are met. Combining both AppState objects and controls can be quite powerful! You often use AppState objects to work with certain subsets of spatials that all carry one specific control.

A control can add custom methods to its spatial, and the AppState object can call these methods to make individual spatials do the AppState object's bidding. As an example, let's make the scared cubes identify themselves by name, and count how often cubes get scared in total.

  1. Add the following custom method to the CubeChaserControl class:
    public String hello(){ return "Hello, ...

Get jMonkeyEngine 3.0 Beginner's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.