Game Development Reference
In-Depth Information
//Retrieves the impassable path matrix for all layers on the current stage
currNotIn = layerList.getTotalNotInMatrix();
//Initializes hero's position, level, and other attributes
initHeroData();
//Creates monsters and initializes their attributes
monsterNumber = GameData.getMonsterNumberByStage(currStage);
monsterLocation
=
GameData.getMonsterLocationByStage(currStage);
monsterArray =
new
Monster[monsterNumber];
for
(
int
i=0;i<monsterNumber;i++){
int
monsterId = Math.random()<0.5?0:1;
//0;
monsterArray[i] =
new
Monster(monsterId+1,monsterLocation[i][0],
monsterLocation[i][1],
this
);
monsterArray[i].makeAnimation(
BitmapManager.getMonsterFrmList(monsterId));
}
}
myTouchEvent() Method
It's a customized event handling method which will capture the touch events on the screen
and takes the corresponding actions.
//Customized handle method of touch events. Captures the touch event
//on the screen and takes the corresponding actions.
//Parameters:
// x - x coordinate of the screen tap
// y - y coordinate of the screen tap
public boolean
myTouchEvent(
int
x,
int
y){
//the real coordinates of the screen tap
this
.cx = x + startCol*TILE_SIZE + offsetX;
this
.cy = y + startRow*TILE_SIZE + offsetY;
//Checks the game state
Search WWH ::
Custom Search