Game Development Reference
In-Depth Information
btnLeaderboard.addEventListener(MouseEvent.
CLICK, onLeaderboard, false, 0, true);
if (!MarbleRunner.gameData.data.level)
{
btnContinueGame.alpha = .5;
btnContinueGame.mouseEnabled = false;
}
}
private function onNewGame(e:MouseEvent):void
{
MarbleRunner.saveGameData(1, 0);
onContinueGame(null);
}
private function onContinueGame(e:MouseEvent):void
{
dispatchEvent(new DataEvent(MarbleRunner.EVENT_
NAVIGATE, true, false, MarbleRunner.FRAME_GAME));
}
private function onHowToPlay(e:MouseEvent):void
{
dispatchEvent(new DataEvent(MarbleRunner.EVENT_
NAVIGATE, true, false, MarbleRunner.
FRAME_HOW_TO_PLAY));
}
private function onLeaderboard(e:MouseEvent):void
{
dispatchEvent(new DataEvent(MarbleRunner.EVENT_
NAVIGATE, true, false, MarbleRunner.
FRAME_LEADERBOARD));
}
}
If there is no save data option, the Continue button is faded out
and disabled. When a new game is started, it saves initial data that
can later be used to continue from where they left off. All of the
other buttons simply dispatch navigation events that the document
class will use to move between screens
pretty straightforward stuff.
Leaderboard
In creating a global leaderboard for a game, Flash developers have a
staggering number of options for communicating storing the data. For
this example (and all others in this topic), the leaderboard connects
Search Nedrilad ::




Custom Search