Game Development Reference
In-Depth Information
hotspot.x = HOSTSPOT_POS_OFFSET_X + x_offset;
hotspot.y = HOSTSPOT_POS_OFFSET_Y + y_offset;
hotspot.addEventListener(MouseEvent.CLICK,
playAction);
x_offset += HOSTSPOT_STRIDE;
}
y_offset += HOSTSPOT_STRIDE;
}
//init the circle BitmapAsset
m_circleBitmapAsset = new Circle() as BitmapAsset;
//init the cross BitmapAsset
m_crossBitmapAsset = new Cross() as BitmapAsset;
}
The implementation looks a bit hairy, but it is essentially doing three things. Firstly, the
tic-tac-toe board (border) is drawn. Next, nine hotspot objects are laid out where the
player may click on the board. Lastly, bitmap assets for circle and cross are initialized.
A player goes in and out of a room (game screen) many times. Every time a player
enters the game room, the show() method is called, and hide() is called whenever
the player leaves the room.
public override function show():void {
super.show();
}
In this game, we choose not to draw anything in the show method, but rather wait
until the game starts. The super.show() calls the show method in the GameScreen
class that displays the go or the wait sprite. The room creator automatically makes
the host for the room and PulseUI will make sure to display the go for the host
player and wait for the other player joining the room.
If no special handling is required for our game, you may very well omit the override;
it is listed here simply for clarity.
 
Search WWH ::




Custom Search