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, shapeRenderer, spriteBatch, 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 |
void |
interpolate(float alpha)
Interpolate the game state
|
void |
onPause() |
void |
onResize(int width,
int height)
Called when the game window changes dimensions.
|
void |
onResume() |
protected void |
postinit()
Internal post-initialisation code
|
protected void |
preinit()
Internal pre-initialisation code
|
void |
render(Graphics g)
Render the game
|
void |
update(float delta)
Update the game
|
createStage, dispose, getHeight, getWidth, initialise, 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 onResize(int width, int height)
GameContainer
onResize
in class GameContainer
width
- The new game window widthheight
- The new game window heightpublic 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()
GameContainer
preinit
in class GameContainer
protected void postinit()
GameContainer
postinit
in class GameContainer