Game Development Reference
In-Depth Information
}
private function onMouseOut(e:MouseEvent):void {
width = width-10;
height = height-10;
}
private function onMouseClick(e:MouseEvent):void {
m_mgr.playCard(this);
}
public function get gameState():GameStateClient {
return m_gs;
}
public function set gameState(gs:GameStateClient):void {
m_gs = gs;
}
}
}
All cards are managed by the
CardManager
class. Each card is first put into the deck
(
m_deck
) array property. The
m_myHand
array consists of cards that belong to the
player. The
m_others
array consists of cards that belong to other players.
Cards are moved from one array to the other by calling the appropriate method.
For example,
toMyHand
moves the card from the deck to the
myHand
array. The
allToDeck
method will move all the cards in
myHand
and in others to the deck
and so on.
Here is the full listing of the
CardManager
class:
package jjf.game
{
import flash.display.BitmapData;
import jjf.graphics.Asset;
import jjf.ui.Game;
public class CardManager
{
private var m_nextId:int=1;
private var m_game:Game;
private var m_deck:Array = new Array();
private var m_myHand:Array = new Array();
private var m_others:Array = new Array();
private var m_colors:Array = new Array();