@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); }
@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); } }
@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); } }
@Override public void removeEntity(GameScreenEntity entity) { gameScreens.remove(entity.getId()); }
@Override public void addEntity(GameScreenEntity entity) { gameScreens.put(entity.getId(), entity); }
@Override public void interpolate(GameContainer gc, float alpha) { if (currentScreen != null) { currentScreen.interpolate(gc, alpha); } }