Game Development Reference
In-Depth Information
Then, modify the create() and render() methods, as shown in the following
code snippet:
@Override
public void create () {
// Set Libgdx log level to DEBUG
Gdx.app.setLogLevel(Application.LOG_DEBUG);
// Initialize controller and renderer
worldController = new WorldController();
worldRenderer = new WorldRenderer(worldController);
// Game world is active on start
paused = false;
}
@Override
public void render () {
// Do not update game world when paused.
if (!paused) {
// Update game world by the time that has passed
// since last rendered frame.
worldController.update(Gdx.graphics.getDeltaTime());
}
// Sets the clear screen color to: Cornflower Blue
Gdx.gl.glClearColor(0x64/255.0f, 0x95/255.0f, 0xed/255.0f,
0xff/255.0f);
// Clears the screen
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
// Render game world to screen
worldRenderer.render();
}
Lastly, add the following code to pause() and resume() in order to let the game
respond to these events by setting paused to the correct state:
@Override
public void pause () {
paused = true;
}
@Override
public void resume () {
paused = false;
}
 
Search WWH ::




Custom Search