Game Development Reference
In-Depth Information
soundManager.addSound(SOUND_GAME_LOST,new Library.SoundGameLost);
soundManager.addSound(SOUND_LEVEL_COMPLETE,new Library.SoundLevelComplete);
soundManager.addSound(SOUND_SKULL_HIT,new Library.SoundSkullHit);
soundManager.addSound(SOUND_PLAYER_START,new Library.SoundPlayerStart);
soundManager.addSound(SOUND_HIT_WALL,new Library.SoundHitWall);
//*** Flash IDE SDK
//soundManager.addSound(SOUND_TITLE_MUSIC,new SoundTitleMusic);
//soundManager.addSound(SOUND_CAR, new SoundCar);
//soundManager.addSound(SOUND_CLOCK_PICKUP,new SoundClockPickup);
//soundManager.addSound(SOUND_HEART_PICKUP,new SoundHeartPickup);
//soundManager.addSound(SOUND_GAME_LOST,new SoundGameLost);
//soundManager.addSound(SOUND_LEVEL_COMPLETE,new SoundLevelComplete);
//soundManager.addSound(SOUND_SKULL_HIT,new SoundSkullHit);
//soundManager.addSound(SOUND_PLAYER_START,new SoundPlayerStart);
//soundManager.addSound(SOUND_HIT_WALL,new SoundHitWall);
If you are using the Flash IDE, you will want to comment out the Flex SDK addSound function
calls and uncomment the Flash IDE versions.
Again, like in the previous chapters, we created override functions for the
systemTitle
and
systemNewGame
functions to handle the title screen music.
Transitioning to the LevelInScreen
One of the biggest changes in this version of
Main
is the coding on the
leveInScreen
transition in
the. Our
game
class instance will be positioned at
404x
to begin the game.
game.x = 404;
We have also created an override function for the
systemWait
function.
During the
STATE_SYSTEM_LEVEL_IN
state, this new function will move the game screen from the
right-hand side of the stage to the
0 x
position where the game play will start. Also, the game
levelInScreen
will fade out by decrementing its alpha value.
if (lastSystemState == FrameWorkStates.STATE_SYSTEM_LEVEL_IN) {
game.x -= 2;
if (game.x < 100) {
levelInScreen.alpha -= .01;
if (levelInScreen.alpha < 0 ) {
levelInScreen.alpha = 0;
}
}
if (game.x <= 0) {
game.x = 0;
soundManager.playSound(SOUND_PLAYER_START, false,1,20, 1);
dispatchEvent(new Event(EVENT_WAIT_COMPLETE));
}
}
Notice also that once the levelInScreen is in its final position we have a sound that plays
(SOUND_PLAYER_START) to indicate the level has begun.