Game Development Reference
In-Depth Information
private function checkForFadingDice():Boolean {
var fading:Boolean = false;
for (var r:int = 0; r < board.length; r++) {
for (var c:int = 0; c < board[r].length; c++) {
tempDie =board[r][c];
if (tempDie != null) {
if (tempDie.isFading) {
fading = true;
}
}
}
}
return fading;
}
private function replaceDice():void {
for (var r:int = 0; r < board.length; r++) {
for (var c:int = 0; c < board[r].length; c++) {
if (board[r][c] == null) {
board[r][c] = addDie(r,c);
}
}
}
}
private function addDie(row:Number, col:Number):Die {
var randomColor:Number = Math.floor(Math.random()*currentLevel.allowedColors.length);
var dieColor:Number = currentLevel.allowedColors[randomColor];
var dieValue:Number = Math.floor(Math.random() * 6)+1;
tempDie = new Die(dieValue, dieColor, tileSheet, row, col,
(row*DIE_HEIGHT)+Y_PAD+(row*ROW_SPACING),(Math.random()*10)+10 );
tempDie.x=(col*DIE_WIDTH)+X_PAD+(col*COL_SPACING);
tempDie.y= 0 - DIE_HEIGHT;
tempDie.addEventListener(CustomEventClickDie.EVENT_CLICK_DIE, dieClickListener,
false, 0, true);
this.addChild(tempDie);
return tempDie;
}
private function update():void {
for (var r:int = 0; r < board.length; r++) {
for (var c:int = 0; c < board[r].length; c++) {
tempDie = board[r][c];
if (tempDie != null) {
if (tempDie.isFalling) {
tempDie.update();
}
}
}
}
}
private function render():void {
for (var r:int = 0; r < board.length; r++) {
Search WWH ::




Custom Search