/** * Get the next transition pair that we'lluse * * @return The pair of transitions used to enter and leave the next state */ public Transition[] getNextTransitionPair() { Transition[] pair = new Transition[2]; try { if (transitions[index][0] != null) { pair[0] = (Transition) transitions[index][0].newInstance(); } if (transitions[index][1] != null) { pair[1] = (Transition) transitions[index][1].newInstance(); } } catch (Throwable e) { Log.error(e); } index++; if (index >= transitions.length) { index = 0; } return pair; }
/** * @see org.newdawn.slick.state.GameState#update(org.newdawn.slick.GameContainer, org.newdawn.slick.state.StateBasedGame, int) */ public void update(GameContainer container, StateBasedGame game, int delta) throws SlickException { if (container.getInput().isKeyPressed(Input.KEY_SPACE)) { Transition[] pair = getNextTransitionPair(); game.enterState(next, pair[0], pair[1]); } }
/** * Transits to a the specified game state. * This method hides the UI of the current state before starting the transition. * * @param id The ID of the state to enter * @param leave The transition to use when leaving the current state * @param enter The transition to use when entering the new state * @see StateBasedGame#enterState(int, org.newdawn.slick.state.transition.Transition, org.newdawn.slick.state.transition.Transition) */ @Override public void enterState(int id, Transition leave, Transition enter) { if(gui != null) { gui.setRootPane(emptyRootWidget); } super.enterState(id, leave, enter); }
/** * Transits to a the specified game state. * This method hides the UI of the current state before starting the transition. * * @param id The ID of the state to enter * @param leave The transition to use when leaving the current state * @param enter The transition to use when entering the new state * @see StateBasedGame#enterState(int, org.newdawn.slick.state.transition.Transition, org.newdawn.slick.state.transition.Transition) */ @Override public void enterState(int id, Transition leave, Transition enter) { if (gui != null) { gui.setRootPane(emptyRootWidget); } super.enterState(id, leave, enter); }
/** * Transits to a the specified game state. This method hides the UI of the * current state before starting the transition. * * @param id * The ID of the state to enter * @param leave * The transition to use when leaving the current state * @param enter * The transition to use when entering the new state * @see StateBasedGame#enterState(int, * org.newdawn.slick.state.transition.Transition, * org.newdawn.slick.state.transition.Transition) */ @Override public void enterState(int id, Transition leave, Transition enter) { if (gui != null) { gui.setRootPane(emptyRootWidget); } super.enterState(id, leave, enter); }
/** * Transits to a the specified game state. This method hides the UI of the * current state before starting the transition. * * @param id The ID of the state to enter * @param leave The transition to use when leaving the current state * @param enter The transition to use when entering the new state * @see StateBasedGame#enterState(int, * org.newdawn.slick.state.transition.Transition, * org.newdawn.slick.state.transition.Transition) */ @Override public void enterState(int id, Transition leave, Transition enter) { super.enterState(id, leave, enter); }