Game Development Reference
In-Depth Information
This will apply the correct skin color by tinting the image of the bunny head. Next,
add the following import line to WorldRenderer :
import com.packtpub.libgdx.canyonbunny.util.GamePreferences;
After this, make the following change to the same class:
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 collected feather icon (anchored to top left edge)
renderGuiFeatherPowerup(batch);
// draw extra lives icon + text (anchored to top right edge)
renderGuiExtraLive(batch);
// draw FPS text (anchored to bottom right edge)
if (GamePreferences.instance.showFpsCounter)
renderGuiFpsCounter(batch);
// draw game over text
renderGuiGameOverMessage(batch);
batch.end();
}
This change will make the FPS counter appear only if the checkbox has been ticked
in the Options window. Otherwise, the FPS counter will not be drawn to the scene.
Summary
In this chapter, you learned how to manage multiple screens and how to switch
between them. We discussed what a scene graph is and how it basically works in
LibGDX in conjunction with Scene2D UI, TableLayout , and skins to create complex
user interfaces like the one we have now implemented in Canyon Bunny. You also
learned how input events for widgets can be handled.
In the next chapter, you will learn how to enhance the visual appearance of the
game. Among others, we will use particle effects and interpolation algorithms to
achieve special effects.
 
Search WWH ::




Custom Search