Game Development Reference
In-Depth Information
@Override
public void
update(
float
deltaTime) {
List<TouchEvent> touchEvents = game.getInput().getTouchEvents();
game.getInput().getKeyEvents();
int
len = touchEvents.size();
for
(
int
i = 0; i < len; i++) {
TouchEvent event = touchEvents.get(i);
touchPoint.set(event.x, event.y);
guiCam.touchToWorld(touchPoint);
if
(event.type == TouchEvent.
TOUCH
_
UP
) {
if
(OverlapTester.
pointInRectangle
(backBounds, touchPoint)) {
game.setScreen(
new
MainMenuScreen(game));
return
;
}
}
}
}
The
update()
method just checks whether the arrow button was pressed. If it was, it plays the
click sound and transitions back to the main menu screen.
@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(160, 240, 320, 480, 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(160, 360, 300, 33, Assets.
highScoresRegion
);
float
y = 240;
for
(
int
i = 4; i >= 0; i--) {
Assets.
font
.drawText(batcher, highScores[i], xOffset, y);
y += Assets.
font
.glyphHeight;
}
batcher.drawSprite(32, 32, 64, 64, Assets.
arrow
);
batcher.endBatch();
gl.glDisable(GL10.
GL
_
BLEND
);
}