public abstract class ScreenBasedGame extends GameContainer
GameContainer
that allows for separation of a
game into multiple GameScreen
s and provides support for
Transition
s between such screens via a ScreenManager
graphics, height, MAXIMUM_DELTA, polygonSpriteBatch, shapeRenderer, spriteBatch, TARGET_FPS, width
Constructor and Description |
---|
ScreenBasedGame() |
Modifier and Type | Method and Description |
---|---|
void |
addScreen(GameScreen screen)
Add a
GameScreen to this game |
void |
enterGameScreen(int id,
Transition transitionOut,
Transition transitionIn)
Begins a transition to a new
GameScreen |
abstract int |
getInitialScreenId()
Returns the identifier of the
GameScreen that should be shown
when the game starts |
ScreenManager<GameScreen> |
getScreenManager()
Returns the
ScreenManager used by this game |
void |
interpolate(float alpha)
Interpolate the game state
|
void |
onPause() |
void |
onResume() |
protected void |
postinit()
Internal post-initialisation code
|
protected void |
preinit(Graphics g)
Internal pre-initialisation code
|
void |
render(Graphics g)
Render the game
|
void |
update(float delta)
Update the game
|
addResizeListener, createStage, dispose, getHeight, getWidth, initialise, removeResizeListener, render, resize, start
public abstract int getInitialScreenId()
GameScreen
that should be shown
when the game startsGameScreen
identifier via GameScreen
.getId()public void update(float delta)
GameContainer
update
in class GameContainer
delta
- The time in seconds since the last updatepublic void interpolate(float alpha)
GameContainer
interpolate
in class GameContainer
alpha
- The alpha value to use during interpolationpublic void render(Graphics g)
GameContainer
render
in class GameContainer
g
- The Graphics
context available for renderingpublic void onPause()
onPause
in class GameContainer
public void onResume()
onResume
in class GameContainer
public void addScreen(GameScreen screen)
GameScreen
to this gamescreen
- The GameScreen
to be addedpublic void enterGameScreen(int id, Transition transitionOut, Transition transitionIn)
GameScreen
id
- The id of the GameScreen
to transition totransitionOut
- The outgoing Transition
, e.g. fade outtransitionIn
- The incoming Transition
, e.g. fade inprotected void preinit(Graphics g)
GameContainer
preinit
in class GameContainer
protected void postinit()
GameContainer
postinit
in class GameContainer
public ScreenManager<GameScreen> getScreenManager()
ScreenManager
used by this game