Game Development Reference
In-Depth Information
them from some other type of DisplayObject. For that matter, they
could even be Shape objects that draw their contents dynamically;
theenginedoesn
'
tcareaslongastheinterfaceisimplemented
properly.
Results
The final screen in Marble Runner is the results screen, where the
player
s score is totaled and can be submitted to the high-score
table. Figure 15.13 shows how this screen looks in practice.
'
final public class Results extends Sprite
{
public var btnPostScore:SimpleButton;
public var btnContinue:SimpleButton;
public var btnQuit:SimpleButton;
public var tfScore:TextField;
public var tfName:TextField;
public function Results()
{
addEventListener(Event.ADDED_TO_STAGE,
onAddedToStage, false, 0, true);
}
private function onAddedToStage(e:Event):void
{
tfScore.text = String(MarbleRunner.gameData.data.
score);
tfName.restrict = " A-Z " ;
btnPostScore.addEventListener(MouseEvent.CLICK,
onPostScore, false, 0, true);
btnContinue.addEventListener(MouseEvent.CLICK,
onContinue, false, 0, true);
btnQuit.addEventListener(MouseEvent.CLICK,
onQuit, false, 0, true);
}
private function onPostScore(e:MouseEvent):void
{
if (tfName.length
<
3)
{
return;
}
Leaderboard.saveScore(MarbleRunner.gameData.
data.score, tfName.text.toUpperCase());
btnPostScore.removeEventListener(MouseEvent.
CLICK, onPostScore);
Figure 15.13 The results screen
of Marble Runner.
Search Nedrilad ::




Custom Search