Time for action – reload settings

Let's assume you want to use settings.setResolution() to change the resolution while playing a cut scene. If the game is already running, changing application settings has no effect, unless you reload them.

  1. Make a copy of Main.java and name the class ReloadSettings.java. Remember to also refactor the first line of the main() method to ReloadSettings app = new ReloadSettings();.
  2. Add the following temporary variable and code to the simpleUpdate() method:
    float temp;
    public void simpleUpdate(float tpf) {
      // a trivial 2-second timer
      temp+=tpf;
      if( temp>2 ) { restartDemo(); temp=0; }
    }
  3. Add the following custom demo method:
    private void restartDemo() { settings.setResolution(FastMath.nextRandomInt(100, 800),FastMath.nextRandomInt(100, ...

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.