Game Development Reference
In-Depth Information
if (OverlapTester. pointInRectangle (backBounds, touchPoint)) {
Assets. playSound (Assets. clickSound );
game.setScreen( new MainMenuScreen(game));
}
}
}
The update() method fetches the touch events and checks whether a “touch-up� event has
been registered. If so, it transforms the touch coordinates to the camera's coordinate system.
With these coordinates, it tests the various rectangles to decide what action to take.
@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(Assets. background );
batcher.drawSprite(240, 160, 480, 320, Assets. backgroundRegion );
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(240, 280, 224, 32, Assets. settingsRegion );
batcher.drawSprite(120, 160, 64, 64,
Settings. touchEnabled ? Assets. touchEnabledRegion : Assets. touchRegion );
batcher.drawSprite(240, 160, 64, 64,
Settings. touchEnabled ? Assets. accelRegion
: Assets. accelEnabledRegion );
batcher.drawSprite(360, 160, 64, 64,
Settings. soundEnabled ? Assets. soundEnabledRegion : Assets. soundRegion );
batcher.drawSprite(32, 32, 64, 64, Assets. leftRegion );
batcher.endBatch();
gl.glDisable(GL10. GL_BLEND );
gl.glDisable(GL10. GL_TEXTURE_2D );
}
The present() method does the same thing as the MainMenuScreen.render() method. We render
the background and buttons with texturing and blending where needed. Based on the current
settings, we decide which TextureRegion to use to render the three settings buttons.
@Override
public void pause() {
}
@Override
public void resume() {
}
 
Search WWH ::




Custom Search