예제 #1
0
  @Override
  public void onDrawFrame(GL10 gl) {
    GLGameState state = null;

    synchronized (stateChanged) {
      state = this.state;
    }

    if (state == GLGameState.Running) {
      float deltaTime = (System.nanoTime() - startTime) / 1000000000.0f;
      startTime = System.nanoTime();

      screen.update(deltaTime);
      screen.present(deltaTime);
    }

    if (state == GLGameState.Paused) {
      screen.pause();
      synchronized (stateChanged) {
        this.state = GLGameState.Idle;
        stateChanged.notifyAll();
      }
    }

    if (state == GLGameState.Finished) {
      screen.pause();
      screen.dispose();
      synchronized (stateChanged) {
        this.state = GLGameState.Idle;
        stateChanged.notifyAll();
      }
    }
  }
예제 #2
0
  @Override
  public void setScreen(Screen screen) {
    if (screen == null) throw new IllegalArgumentException("Screen must not be null");

    this.screen.pause();
    this.screen.dispose();
    screen.resume();
    screen.update(0);
    this.screen = screen;
  }