Game Development Reference
In-Depth Information
public void explosion() {
Assets. playSound (Assets. explosionSound );
}
};
world.setWorldListener(worldListener);
renderer = new WorldRenderer(glGraphics);
pauseBounds = new Rectangle(480-64, 320-64, 64, 64);
resumeBounds = new Rectangle(240-80, 160, 160, 32);
quitBounds = new Rectangle(240-80, 160-32, 160, 32);
shotBounds = new Rectangle(480-64, 0, 64, 64);
leftBounds = new Rectangle(0, 0, 64, 64);
rightBounds = new Rectangle(64, 0, 64, 64);
lastScore = 0;
lastLives = world.ship.lives;
lastWaves = world.waves;
scoreString = "lives:" + lastLives + " waves:" + lastWaves + " score:"
+ lastScore;
fpsCounter = new FPSCounter();
}
In the constructor, we set up all the members, as we are now accustomed to doing. The
WorldListener is responsible for playing the correct sound when an event occurs in our world.
The rest is the same as for Super Jumper, though adapted slightly for the somewhat different
UI elements.
@Override
public void update( float deltaTime) {
switch (state) {
case GAME_PAUSED :
updatePaused();
break ;
case GAME_RUNNING :
updateRunning(deltaTime);
break ;
case GAME_OVER :
updateGameOver();
break ;
}
}
The update() method delegates the real updating to one of the other three update methods,
depending on the current state of the screen.
private void updatePaused() {
List<TouchEvent> events = game.getInput().getTouchEvents();
int len = events.size();
for ( int i = 0; i < len; i++) {
TouchEvent event = events.get(i);
if (event.type != TouchEvent. TOUCH_UP )
continue ;
 
Search WWH ::




Custom Search