Game Development Reference
In-Depth Information
The JigsawGameScreen class
Lastly, there is the class where all the action happens inside of the game room, once
the game has started. This class contains a few important objects that are required to
manage the puzzle pieces that we saw earlier in the chapter. The DisplayManager
instance that shows the group management and finish logic, a MiniMap instance
that shows the miniature image of the puzzle, and an image that is shown once the
puzzle is completed are all initialized during the init method.
The show method adds all the above three sprite objects as child, so they are ready
to be displayed. The hide method cleans up everything and removes the sprites from
the screen.
When the game is started by the game host, the startGame method is called,
where we create the pieces and groups as well as display the mini-map. The
implementation in this class is simple, as all the hard work is done by the class we
saw earlier, such as DisplayManager, PieceSprite, Group, and so on.
Here is the complete listing of the class:
package jig.ui
{
import flash.display.BitmapData;
import jig.JigsawGame;
import jig.game.DisplayManager;
import jig.game.MiniMap;
import jig.game.PuzzlePix;
import jig.game.Mask;
import mx.core.BitmapAsset;
import pulseui.GameScreen;
public class JigsawGameScreen extends GameScreen
{
private var bmd:BitmapData;
[Embed(source="jig\\rsrc\\ml.jpg")]
private var MLClass: Class;
// The puzzle manager
private var m_displayManager:DisplayManager;
// To show the puzzle image
private var m_miniMap:MiniMap;
//private var m_playBtn:PlayBtnSprite;
// A completed puzzle image
private var m_pp:PuzzlePix;
 
Search WWH ::




Custom Search