예제 #1
0
  @Override
  public void update(GameContainer gc, float delta) {
    if (transitionOut != null) {
      transitionOut.update(gc, delta);
      if (transitionOut.isFinished()) {
        if (currentScreen != null) {
          currentScreen.postTransitionOut(transitionOut);
        }
        GameScreen oldScreen = currentScreen;
        currentScreen = nextScreen;
        nextScreen = null;
        transitionOut = null;

        if (transitionIn != null) {
          currentScreen.preTransitionIn(transitionIn);
        }
      } else {
        return;
      }
    }

    if (transitionIn != null) {
      transitionIn.update(gc, delta);
      if (transitionIn.isFinished()) {
        currentScreen.postTransitionIn(transitionIn);
        transitionIn = null;
      } else {
        return;
      }
    }

    currentScreen.update(gc, this, delta);
  }
예제 #2
0
  @Override
  public void enterGameScreen(int id, Transition transitionOut, Transition transitionIn) {
    if (transitionOut == null) {
      transitionOut = new NullTransition();
    }
    if (transitionIn == null) {
      transitionIn = new NullTransition();
    }
    this.transitionIn = transitionIn;
    this.transitionOut = transitionOut;

    this.nextScreen = gameScreens.get(id);
    this.transitionOut.initialise(currentScreen, nextScreen);

    if (currentScreen != null) {
      currentScreen.preTransitionOut(transitionOut);
    }
  }
예제 #3
0
  @Override
  public void render(GameContainer gc, Graphics g) {
    if (transitionOut != null) {
      transitionOut.preRender(gc, g);
    } else if (transitionIn != null) {
      transitionIn.preRender(gc, g);
    }

    if (currentScreen != null) {
      currentScreen.render(gc, g);
    }

    if (transitionOut != null) {
      transitionOut.postRender(gc, g);
    } else if (transitionIn != null) {
      transitionIn.postRender(gc, g);
    }
  }
예제 #4
0
 @Override
 public void removeEntity(GameScreenEntity entity) {
   gameScreens.remove(entity.getId());
 }
예제 #5
0
 @Override
 public void addEntity(GameScreenEntity entity) {
   gameScreens.put(entity.getId(), entity);
 }
예제 #6
0
 @Override
 public void interpolate(GameContainer gc, float alpha) {
   if (currentScreen != null) {
     currentScreen.interpolate(gc, alpha);
   }
 }