Game Development Reference
In-Depth Information
An FPS counter that shows the text FPS followed by the current number of frames
per second is drawn in the bottom-right corner of the screen. The color of the text
depends on the achieved frame rate. If the FPS is 45 or higher, the text will show up
in green, indicating a good rendering performance. Otherwise, if there are 30 or more
FPS, then the text will show up in yellow, which indicates an average rendering
performance. Anything below 30 FPS will show up in red, indicating a really poor
rendering performance.
Rendering the GUI
Add the following code in WorldRenderer :
private void renderGui (SpriteBatch batch) {
batch.setProjectionMatrix(cameraGUI.combined);
batch.begin();
// draw collected gold coins icon + text
// (anchored to top left edge)
renderGuiScore(batch);
// draw extra lives icon + text (anchored to top right edge)
renderGuiExtraLive(batch);
// draw FPS text (anchored to bottom right edge)
renderGuiFpsCounter(batch);
batch.end();
}
Furthermore, change render() in WorldRenderer :
public void render () {
renderWorld(batch);
renderGui(batch);
}
The implementation of the game's GUI is now finished.
 
Search WWH ::




Custom Search