Game Development Reference
In-Depth Information
Next up is the update() method, which simply checks whether the arrow button was pressed. If
it was pressed, we transition to the next help screen. We also play the click sound.
@Override
public void present( float deltaTime) {
GL10 gl = glGraphics.getGL();
gl.glClear(GL10. GL _ COLOR _ BUFFER _ BIT );
guiCam.setViewportAndMatrices();
gl.glEnable(GL10. GL _ TEXTURE _ 2D );
batcher.beginBatch(helpImage);
batcher.drawSprite(160, 240, 320, 480, helpRegion);
batcher.endBatch();
gl.glEnable(GL10. GL _ BLEND );
gl.glBlendFunc(GL10. GL _ SRC _ ALPHA , GL10. GL _ ONE _ MINUS _ SRC _ ALPHA );
batcher.beginBatch(Assets. items );
batcher.drawSprite(320 - 32, 32, -64, 64, Assets. arrow );
batcher.endBatch();
gl.glDisable(GL10. GL _ BLEND );
}
@Override
public void dispose() {
}
}
In the present() method, we clear the screen, set up the matrices, render the help image in one
batch, and then render the arrow button. Of course, we don't need to render the background
image here, as the help image already contains that.
The other help screens are analogous, as previously outlined.
The High-Scores Screen
Next on our list is the high-scores screen. Here, we'll use part of the main menu UI labels (the
HIGHSCORES portion) and render the high scores stored in Settings via the Font instance we
store in the Assets class. Of course, we have an arrow button so that the player can get back to
the main menu. Listing 9-8 shows the code.
Listing 9-8. HighscoresScreen.java, the High-Scores Screen
package com.badlogic.androidgames.jumper;
import java.util.List;
import javax.microedition.khronos.opengles.GL10;
 
Search WWH ::




Custom Search