Game Development Reference
In-Depth Information
Add the following code in WorldRenderer :
private void renderGuiScore (SpriteBatch batch) {
float x = -15;
float y = -15;
batch.draw(Assets.instance.goldCoin.goldCoin,
x, y, 50, 50, 100, 100, 0.35f, -0.35f, 0);
Assets.instance.fonts.defaultBig.draw(batch,
"" + worldController.score,
x + 75, y + 37);
}
The gold coin image is drawn in the top-left corner of the screen. Next to it, the
player's current score is displayed using the big default font.
The GUI extra lives
The following is a screenshot of the GUI element that shows the player's remaining
extra lives:
Add the following code in WorldRenderer :
private void renderGuiExtraLive (SpriteBatch batch) {
float x = cameraGUI.viewportWidth - 50 -
Constants.LIVES_START * 50;
float y = -15;
for (int i = 0; i < Constants.LIVES_START; i++) {
if (worldController.lives <= i)
batch.setColor(0.5f, 0.5f, 0.5f, 0.5f);
batch.draw(Assets.instance.bunny.head,
x + i * 50, y, 50, 50, 120, 100, 0.35f, -0.35f, 0);
batch.setColor(1, 1, 1, 1);
}
}
 
Search WWH ::




Custom Search