Game Development Reference
In-Depth Information
We override the parent class' implementation onNewGameState and insert what is
required for this game. First, we figure out which player has successfully added the
game state (matched a piece), then incremented the score for the player, and then
call the onPieceMatch method to visually update the screen so as to make the pieces
appear attached.
The JigsawSkinner class
We need to subclass the skinner to read in the image (skin) files that will be used to
draw all the UI for all of the screens.
public class JigsawSkinner extends Skinner
{
[Embed(source="jig\\rsrc\\Outline.png")]
private static var OutlineClass:Class;
[Embed(source="jig\\rsrc\\ui.png")]
private static var UIClass:Class;
[Embed(source="jig\\rsrc\\frame.png")]
private static var FrameClass:Class;
public function JigsawSkinner() {
}
protected override function load():void {
m_outline = (new OutlineClass() as BitmapAsset).
bitmapData;
m_ui = (new UIClass() as BitmapAsset).bitmapData;
m_frame = (new FrameClass() as BitmapAsset).bitmapData;
}
}
The custom skinner is quite simple. The previous code is the complete listing for the
class. The load method should be overridden to create BitmapAsset for the outline,
ui, and frame. These are protected fields defined in the Skinner class. The Skinner
object will do all the hard work of cutting up the asset and piecing it altogether
during runtime.
 
Search WWH ::




Custom Search