Game Development Reference
In-Depth Information
_netConnection.call( " games.HighScores.getScores " ,
responder, GAME_ID, NUMBER_OF_RESULTS);
}
private function onScoresLoaded(result:Object):void
{
if (result is Array)
{
var scores:Array = result as Array;
tfRank.text = "" ;
tfInitials.text = "" ;
tfScores.text = "" ;
tfStatusMessage.text = "" ;
for (var i:int = 0; i < scores.length; i++)
{
tfRank.appendText(String(i+1) +
);
tfInitials.appendText(scores[i].initials +
"
\n
"
"
\n
"
);
tfScores.appendText(scores[i].score+
"
\n
"
);
}
}
}
private function onScoresLoadedError(result:Object):void
{
tfStatusMessage.text = STATUS_MESSAGE_ERROR;
}
private function onBack(e:MouseEvent):void
{
dispatchEvent(new DataEvent(MarbleRunner.EVENT_NAVIGATE,
true, false, MarbleRunner.FRAME_TITLE));
}
As you can see, when a leaderboard screen is instantiated and
added to the Stage, it calls the same createConnection method we
looked at earlier. It then proceeds to load the scores from the data-
base. Note how the call is similarly formed to the saveScore
method. Once the scores are loaded in, the data is appended to
the different text columns as shown in Fig. 15.10 .Ifthescoresfail
to load for some reason, the generic error message is displayed in
lieu of the data.
GameClip
Once a new game is started, the GameClip class is instantiated. It
creates an instance of the LabyrinthEngine we looked at earlier and
keeps track of the timer and the player
'
s current level (based on
Figure 15.10 The Leaderboard
screen of Marble Runner.
the data stored in the shared object).
Search Nedrilad ::




Custom Search