Game Development Reference
In-Depth Information
addChild(wallSprite as DisplayObject);
}
}
protected function createEnemies():void {
_enemies = new Array();
var enemies:XMLList = _currentLevel.enemies.children();
for (var i:int = 0; i < enemies.length(); i++) {
var enemyClass:Class = getAssetClass(enemies[i].
@spriteClass);
var enemySprite:IEnemy = new enemyClass();
enemySprite.x = Number(enemies[i].@x) * Number
(_currentLevel.@gridSquareSize);
enemySprite.y = Number(enemies[i].@y) * Number
(_currentLevel.@gridSquareSize);
enemySprite.name = enemies[i].@name;
_enemies.push(enemySprite);
var gridReference:GridReference = _collisionGrid.
getGridReference(Number(enemies[i].@x),
Number(enemies[i].@y));
gridReference.enemies.push(enemySprite);
enemySprite.gridReference = gridReference;
addChild(enemySprite as DisplayObject);
}
}
protected function createItems():void {
_items = new Array();
var items:XMLList = _currentLevel.items.children();
for (var i:int = 0; i
items.length(); i++) {
var itemClass:Class = getAssetClass(items[i].
@spriteClass);
var itemSprite:IItem = new itemClass();
itemSprite.x = Number(items[i].@x) * Number
(_currentLevel.@gridSquareSize);
itemSprite.y = Number(items[i].@y) * Number
(_currentLevel.@gridSquareSize);
itemSprite.points = Number(items[i].@points);
itemSprite.name = items[i].@name;
itemSprite.type = items[i].@type;
_items.push(itemSprite);
var gridReference:GridReference = _collisionGrid.
getGridReference(Number(items[i].@x),
Number(items[i].@y));
gridReference.items.push(itemSprite);
addChild(itemSprite as DisplayObject);
<
}
Search Nedrilad ::




Custom Search