Game Development Reference
In-Depth Information
Constructor
The Game View's Constructor initializes the stage (level) data and creates new threads:
DrawThread, KeyThread, and AIGoThread.
//Constructor: creates a instance of GameView class.
//Initializes stage data and creates new DrawThread,KeyThread, and AIGoThread.
//Parameters:
// context - the specified father's context
public
GameView(RaccoonRob context) {
super
(context);
this
.father = context;
//Initializes stage data
initStageData();
//Add a Callback interface for this holder
getHolder().addCallback(
this
);
//Creates a new DrawThread (main thread)
dt =
new
DrawThread(
this
, getHolder());
//Creates a new KeyThread (captures the screen touch and keyboard events)
kt =
new
KeyThread(
this
);
//Creates a new AIGoThread (AI pathfinding)
aigot =
new
AIGoThread(
this
, monsterArray);
//Sets game state as PLAY
setGameState(STATE_PLAY);
}
doDraw() Method
Called by the DrawThread thread periodically (every 100ms) to draw sprites, maps, bo-
nuses, and other objects.
Search WWH ::
Custom Search