Game Development Reference
In-Depth Information
sahelpful
method for retrieving the total worth of the inventory in points.
If you recall from the level XML, every item has a point attribute;
in some cases, that value is 0, but all of them have it.
In addition to the list of inventory items, there
'
public function destroy():void {
clearReferences();
for (var i:int = numChildren-1; i > =0;i--){
removeChildAt(i);
}
}
protected function clearReferences():void {
_collisionGrid.clear();
_inventory = null;
_walls = null;
_items = null;
_enemies = null;
_portals = null;
_player = null;
for each(var loader:Loader in _assets) {
loader.unload();
}
_assets = null;
_assetQueue = null;
}
Both of these methods are used to perform cleanup on the
engine. Because there are so many pieces of data in so many
containers, it is important to null them all out. Note also that
each of the Loader objects in the asset list call the unload
method on themselves. We
'
ll discuss the level and asset loading
next.
//LEVEL MANAGEMENT
public function loadLevel(uri:String):void {
var request:URLRequest = new URLRequest(uri);
var levelLoader:URLLoader = new URLLoader(request);
levelLoader.addEventListener(Event.COMPLETE,
levelLoaded, false, 0, true);
levelLoader.addEventListener(IOErrorEvent.IO_ERROR,
levelError, false, 0, true);
levelLoader.addEventListener(SecurityErrorEvent.
SECURITY_ERROR, securityError, false, 0, true);
}
protected function levelLoaded(e:Event):void {
_currentLevel = XML(e.target.data);
Search Nedrilad ::




Custom Search