Game Development Reference
In-Depth Information
private void
presentRunning() {
GL10 gl = glGraphics.getGL();
guiCam.setViewportAndMatrices();
gl.glEnable(GL10.
GL_BLEND
);
gl.glBlendFunc(GL10.
GL_SRC_ALPHA
, GL10.
GL_ONE_MINUS_SRC_ALPHA
);
gl.glEnable(GL10.
GL_TEXTURE_2D
);
batcher.beginBatch(Assets.
items
);
batcher.drawSprite(480-32, 320-32, 64, 64, Assets.
pauseButtonRegion
);
Assets.
font
.drawText(batcher, scoreString, 10, 320-20);
if
(Settings.
touchEnabled
) {
batcher.drawSprite(32, 32, 64, 64, Assets.
leftRegion
);
batcher.drawSprite(96, 32, 64, 64, Assets.
rightRegion
);
}
batcher.drawSprite(480-40, 32, 64, 64, Assets.
fireRegion
);
batcher.endBatch();
gl.glDisable(GL10.
GL_TEXTURE_2D
);
gl.glDisable(GL10.
GL_BLEND
);
}
The
presentRunning()
method is also pretty straightforward. We render the
scoreString
first. If
touch input is enabled, we render the left and right movement buttons. Finally, we render the Fire
button and reset any OpenGL ES states we've changed (texturing and blending).
private void
presentGameOver() {
GL10 gl = glGraphics.getGL();
guiCam.setViewportAndMatrices();
gl.glEnable(GL10.
GL_BLEND
);
gl.glBlendFunc(GL10.
GL_SRC_ALPHA
, GL10.
GL_ONE_MINUS_SRC_ALPHA
);
gl.glEnable(GL10.
GL_TEXTURE_2D
);
batcher.beginBatch(Assets.
items
);
batcher.drawSprite(240, 160, 128, 64, Assets.
gameOverRegion
);
Assets.
font
.drawText(batcher, scoreString, 10, 320-20);
batcher.endBatch();
gl.glDisable(GL10.
GL_TEXTURE_2D
);
gl.glDisable(GL10.
GL_BLEND
);
}
The
presentGameOver()
method is more of the sameājust some string and UI rendering.
@Override
public void
pause() {
state =
GAME_PAUSED
;
}
Finally, the
pause()
method simply puts the
GameScreen
into the paused state.