Game Development Reference
In-Depth Information
Creating the Main.as for Tunnel Panic
Some of the changes to Main necessary for this game have already been presented in the earlier
sections where we covered preloading and Mochi services integration. We will need to make a
change to the com.efg.framework.Game.as class to support the lastScore variable. Let's look at
that change first.
Changing Game.as for Tunnel Panic
To support the use of a high score system (in this case the Mochi leader board) we need to make
one small change to com.efg.framework.Game . We need to add the lastScore property to the
variable definition section of that class.
public var lastScore:Number = 0;
Changing Main.as for Tunnel Panic
We've already discussed the changes to the Main.as class for the game, Mochi ads, preloaders,
and high scores. Follow along as we iterate through all rest of the changes necessary for both the
Flex SDK and the Flash IDE version of the Main.as file. The major changes to this class are in
bold to highlight the code necessary for preloading and adding Mochi services.
Note that there are also some code changes to facilitate the screens and sounds for Tunnel
Panic. Since we have discussed these many times already, we will leave those changes for you
to discover on your own.
However, we should note a few interesting things. This game uses the time-based step timer and
frame-rate profiler from Chapter 11. Please refer to that chapter for an in-depth discussion of that
code. Also, the systemWait and systemLevelIn functions are overridden to add a simple alpha
tween for level transition similar to what we created for Chapter 11.
package com.efg.games.tunnelpanic
{
import com.efg.framework.FrameCounter;
import com.efg.framework.FrameRateProfiler;
import flash.text.TextFormat;
import flash.text.TextField;
import flash.text.TextFormatAlign;
import flash.geom.Point;
import flash.events.Event;
import com.efg.framework.FrameWorkStates;
import com.efg.framework.GameFrameWork;
import com.efg.framework.BasicScreen;
import com.efg.framework.ScoreBoard;
import com.efg.framework.SideBySideScoreElement;
import com.efg.framework.SoundManager;
import mochi.as3.*;
dynamic public class Main extends GameFrameWork {
//custom sccore board elements
Search WWH ::




Custom Search