Game Development Reference
In-Depth Information
}
if (game.x <= 0) {
game.x = 0;
soundManager.playSound(SOUND_PLAYER_START, false,1,20, 1);
dispatchEvent(new Event(EVENT_WAIT_COMPLETE));
}
}
private function heartsNeededListener(e:CustomEventHeartsNeeded):void {
heartsToCollect.text = "Collect " + e.heartsNeeded + " Hearts";
heartsToCollect.width = 300;
heartsToCollect.x = 50;
heartsToCollect.y = 200;
}
}
}
We have made some new alterations to the Main class that will change the way the game
interacts with the framework, and we have made the same sort of game-specific changes that we
have seen throughout the topic.
Adding ScoreBoard elements
As with all of the games so far, we have added scoreboard elements for the text fields we want to
display at the top of the screen; there are three in this game: SCORE_BOARD_SCORE will display the
number of points the player has earned by colleting hearts. SCORE_BOARD_TIME_LEFT will display
the number of seconds left for the player to reach the finish line having collected enough hearts to
move on to the next level. SCORE_BOARD_HEARTS will display the number of hearts the player has
collected so far.
public static const SCORE_BOARD_SCORE:String = "score";
public static const SCORE_BOARD_TIME_LEFT:String = "timeleft";
public static const SCORE_BOARD_HEARTS:String = "hearts";
Modifying the screens
The screens have been modified to display the new messaging we want for this game. These are
all pretty straightforward and very similar to the screens in previous games.
Modifying the sounds
We have added nine new sound constants and have added these sounds to the SoundManager .
Unlike in the previous chapter, where the Flex SDK version used an embedded SWF with all of
the sounds included, we will use straight MP3 files this time around. These assets will be
embedded into the library (at design time) of the Flash IDE version but will be embedded at
compile-time in the Flex SDK version.
//*** Flex SDK
soundManager.addSound(SOUND_TITLE_MUSIC,new Library.SoundTitleMusic);
soundManager.addSound(SOUND_CAR, new Library.SoundCar);
soundManager.addSound(SOUND_CLOCK_PICKUP,new Library.SoundClockPickup);
soundManager.addSound(SOUND_HEART_PICKUP,new Library.SoundHeartPickup);
Search WWH ::




Custom Search