Game Development Reference
In-Depth Information
ScreenTransition transition = ScreenTransitionSlice.init(2,
ScreenTransitionSlice.UP_DOWN, 10, Interpolation.pow5Out);
setScreen(new MenuScreen(this), transition);
}
These changes will make sure that after the assets and game preferences have
been loaded, the music starts playing. This is done using the play() method of
AudioManager , which takes care of checking the current audio settings, setting the
correct music volume, and potentially starting the playback of the music file.
LibGDX automatically handles the task of pausing and resuming for
any instances of playing music. Therefore, no extra code is required to
handle these cases in the game code.
Next, add the following import line to the WorldController class:
import com.packtpub.libgdx.canyonbunny.util.AudioManager;
After this, make the following changes to the same class:
public void update (float deltaTime) {
handleDebugInput(deltaTime);
if (isGameOver()) {
timeLeftGameOverDelay -= deltaTime;
if (timeLeftGameOverDelay < 0) backToMenu();
} else {
handleInputGame(deltaTime);
}
level.update(deltaTime);
testCollisions();
cameraHelper.update(deltaTime);
if (!isGameOver() && isPlayerInWater()) {
AudioManager.instance.play(Assets.instance.sounds.liveLost);
lives--;
if (isGameOver())
timeLeftGameOverDelay = Constants.TIME_DELAY_GAME_OVER;
else
initLevel();
}
level.mountains.updateScrollPosition(
cameraHelper.getPosition());
if (livesVisual > lives)
livesVisual = Math.max(lives, livesVisual - 1 * deltaTime);
if (scoreVisual < score)
 
Search WWH ::




Custom Search