Game Development Reference
In-Depth Information
switchSystemState(nextSystemState);
}
Once the showPreGameAd function call is made, the state machine moves into the standard
FrameWorkStates.STATE_SYSTEM_WAIT_FOR_CLOSE state. When the ad is complete or skipped, or if
an error occurs, the mochiAdComplete function is called. You can change these to individual
functions if you have the need or desire to do so. For instance, you might want to sneak in an
advertisement or your own web site in the event that the ad is skipped by the user.
In the Main.as for your specific game, you will need to add the following code:
mochiGameId = "81e8cd4f0999371e";
First, you set the mochiGameId to a specific ID for the game you are making. Again, this ID will
be provided by Mochi when you create a new game for the system. You also need to set the
proper state in Main.as so that the Mochi ad support will fire in the framework. The following line
of code from the previous Main.as classes
switchSystemState(FrameWorkStates.STATE_SYSTEM_TITLE);
needs to change to this new line of code:
switchSystemState(FrameWorkStates.STATE_SYSTEM_MOCHI_AD);
Mochi preloads your game for you as the advertisement plays. However, if you still want to show
your own preloader, you need to override the systemMochiAd function like this.
Note: We have split this Flex SDK and Flash IDE versions. The Flex version will not need to call
the preload sequence after the ad is shown because preloading is completed before the Main.as
is loaded. The Flash IDE version might need preloading after the ad is shown. In any case, once
the ad is shown we can set the framework to jump to the next desired state by overriding the
systemMochiAd function like below.
override public function systemMochiAd():void {
super.systemMochiAd();
//*** flex sdk version
nextSystemState = FrameWorkStates.STATE_SYSTEM_TITLE;
//flash IDE version
//nextSystemState = FrameWorkStates.STATE_SYSTEM_PRELOAD;
}
This function still operates the same as the preceding one, by calling super.systemMochiAd . The
big change is that it changes the systemState to FrameWorkStates.STATE_SYSTEM_PRELOAD so that
preloading will occur. This is only necessary when preloading with the Flash IDE.
Making the leader-board-specific changes
In the init function of Main.as , you will want to add in the following lines to specifically support a
particular game with Mochi services. We have provided only the general code in GameFrameWork ,
so it can be used with any game that needs Mochi services. Some games do not use Mochi
services, so you can manually turn on the service by changing Main.as with the following code
(since we have not created out Main.as class file these are just for example purposes).
mochiBoardId = "ffe2de0ae221a7f4";
MochiServices.connect(mochiGameId, this);
Search WWH ::




Custom Search