| Package | com.pblabs.engine.core |
| Class | public class LevelManager |
| Inheritance | LevelManager flash.events.EventDispatcher |
| Implements | ISerializable |
See also
| Property | Defined By | ||
|---|---|---|---|
| currentLevel : int [read-only]
The level that is currently loaded. | LevelManager | ||
| instance : LevelManager [static] [read-only]
The singleton LevelManager instance. | LevelManager | ||
| levelCount : int [read-only]
Returns the number of levels the LevelManager has data for. | LevelManager | ||
| Method | Defined By | ||
|---|---|---|---|
addFileReference(index:int, filename:String):void
Register a file with a level number. | LevelManager | ||
addGroupReference(index:int, name:String):void
Register a group with a level number. | LevelManager | ||
clear():void
Unload the current level. | LevelManager | ||
deserialize(xml:XML):*
deserializes the object from xml. | LevelManager | ||
getLevelDescription(index:int):LevelDescription | LevelManager | ||
getlevelFiles(index:int):Array
Gets an array of filenames that are to be loaded with a specific level. | LevelManager | ||
getlevelGroups(index:int):Array
Gets an array of group names that are to be loaded with a specific level. | LevelManager | ||
getlevelIndexByName(levelName:String):int
Gets a level index based on the registered level name. | LevelManager | ||
load(filename:String, initialLevel:int = -1):void
Starts up the level manager and loads level description data from an xml file. | LevelManager | ||
loadEntity(name:String):IEntity
Loads an entity with the TemplateManager and tracks it. | LevelManager | ||
loadLevel(index:int, force:Boolean = false):void
Loads the specified level and unloads any previous levels. | LevelManager | ||
loadNextLevel():void
Loads the next level after the current level. | LevelManager | ||
removeFileReference(index:int, filename:String):void
Remove a file from a level number. | LevelManager | ||
removeGroupReference(index:int, name:String):void
Remove a group from a level number. | LevelManager | ||
removeLevel(index:int):void
Removes the level with the specified index. | LevelManager | ||
serialize(xml:XML):void
serializes the object to XML. | LevelManager | ||
setLoadFileCallbacks(load:Function, unload:Function):void
With this method, you can override the default file loading methods by having
custom functions called instead of the defaults. | LevelManager | ||
setLoadGroupCallbacks(load:Function, unload:Function):void
With this method, you can override the default group loading methods by having
custom functions called instead of the defaults. | LevelManager | ||
start(initialLevel:int = -1):void
Starts up the LevelManager. | LevelManager | ||
unloadCurrentLevel():void
Unloads all the currently loaded data. | LevelManager | ||
| Event | Summary | Defined By | ||
|---|---|---|---|---|
| This event is dispatched by the LevelManager when a level's data has been loaded. | LevelManager | |||
| This event is dispatched by the LevelManager when a level's data has been unloaded. | LevelManager | |||
| This event is dispatched by the LevelManager when it is ready to be used. | LevelManager | |||
| currentLevel | property |
currentLevel:int [read-only] The level that is currently loaded.
public function get currentLevel():int| instance | property |
instance:LevelManager [read-only] The singleton LevelManager instance.
public static function get instance():LevelManager| levelCount | property |
levelCount:int [read-only] Returns the number of levels the LevelManager has data for.
public function get levelCount():int| addFileReference | () | method |
public function addFileReference(index:int, filename:String):voidRegister a file with a level number. The same file can be registered with several levels.
Parameters
index:int — The level to register with
| |
filename:String — The file to register
|
| addGroupReference | () | method |
public function addGroupReference(index:int, name:String):voidRegister a group with a level number. The same group can be registered with several levels.
Parameters
index:int — The level to register with
| |
name:String — The name of the group to register
|
| clear | () | method |
public function clear():voidUnload the current level.
| deserialize | () | method |
public function deserialize(xml:XML):*deserializes the object from xml. The format of the xml passed is custom, depending on the way the object was serialized with the serialize method.
Parameters
xml:XML — The xml containing the serialized definition of the class.
|
* — The deserialized object. Usually 'this' should be returned, but in
some cases it may be useful to return something else. The Enumerable class
does this to force all values to be a member of the enumeration.
|
| getLevelDescription | () | method |
public function getLevelDescription(index:int):LevelDescriptionParameters
index:int |
LevelDescription |
| getlevelFiles | () | method |
public function getlevelFiles(index:int):ArrayGets an array of filenames that are to be loaded with a specific level.
Parameters
index:int |
Array |
| getlevelGroups | () | method |
public function getlevelGroups(index:int):ArrayGets an array of group names that are to be loaded with a specific level.
Parameters
index:int |
Array |
| getlevelIndexByName | () | method |
public function getlevelIndexByName(levelName:String):intGets a level index based on the registered level name. Case sensitive. Returns -1 if the level name is not found.
Parameters
levelName:String |
int |
| load | () | method |
public function load(filename:String, initialLevel:int = -1):voidStarts up the level manager and loads level description data from an xml file. Start is automatically called when this finishes.
Parameters
filename:String — The file to load level descriptions from
| |
initialLevel:int (default = -1) — The level to load once everything is set up
|
| loadEntity | () | method |
public function loadEntity(name:String):IEntityLoads an entity with the TemplateManager and tracks it. If the current level ends before the entity is destroyed, it will be destroyed automatically.
Parameters
name:String — The name of the entity to instantiate.
|
IEntity — The created entity.
|
| loadLevel | () | method |
public function loadLevel(index:int, force:Boolean = false):voidLoads the specified level and unloads any previous levels. If the previous level and the new level share data, it will not be reloaded.
Parameters
index:int — The level number to load.
| |
force:Boolean (default = false) — Force reload.
|
| loadNextLevel | () | method |
public function loadNextLevel():voidLoads the next level after the current level.
| removeFileReference | () | method |
public function removeFileReference(index:int, filename:String):voidRemove a file from a level number.
Parameters
index:int — The level to remove from
| |
filename:String — The file to remove
|
| removeGroupReference | () | method |
public function removeGroupReference(index:int, name:String):voidRemove a group from a level number.
Parameters
index:int — The level to remove from
| |
name:String — The group to remove
|
| removeLevel | () | method |
public function removeLevel(index:int):voidRemoves the level with the specified index.
Parameters
index:int — The index of the level to remove.
|
| serialize | () | method |
public function serialize(xml:XML):voidserializes the object to XML. This should not include the main tag defining the class itself.
Parameters
xml:XML — The xml object to which the serialization of this class should
be added. This xml object is a single tag containing the main class definition,
so only children of this class should be added to it.
|
| setLoadFileCallbacks | () | method |
public function setLoadFileCallbacks(load:Function, unload:Function):voidWith this method, you can override the default file loading methods by having custom functions called instead of the defaults.
Parameters
load:Function — The function to call to load files
| |
unload:Function — The function to call to unload files
|
| setLoadGroupCallbacks | () | method |
public function setLoadGroupCallbacks(load:Function, unload:Function):voidWith this method, you can override the default group loading methods by having custom functions called instead of the defaults.
Parameters
load:Function — The function to call to load groups
| |
unload:Function — The function to call to unload groups
|
| start | () | method |
public function start(initialLevel:int = -1):voidStarts up the LevelManager. This is automatically called if level descriptions are loaded from a file with the Load method. Otherwise, this should be called after all the level data has been registered with AddFileReference and AddGroupReference. When everything is ready (except for the initialLevel loading), LevelEvent.READY_EVENT is dispatched.
Parameters
initialLevel:int (default = -1) — The level to load once everything is set up
|
| unloadCurrentLevel | () | method |
public function unloadCurrentLevel():voidUnloads all the currently loaded data. Do not use this when another level is being loaded. Allow the load() method to handle unloading old data.
| LEVEL_LOADED_EVENT | Event |
com.pblabs.engine.core.LevelEventcom.pblabs.engine.core.LevelEvent.LEVEL_LOADED_EVENTThis event is dispatched by the LevelManager when a level's data has been loaded.
| LEVEL_UNLOADED_EVENT | Event |
com.pblabs.engine.core.LevelEventcom.pblabs.engine.core.LevelEvent.LEVEL_UNLOADED_EVENTThis event is dispatched by the LevelManager when a level's data has been unloaded.
| READY_EVENT | Event |
com.pblabs.engine.core.LevelEventcom.pblabs.engine.core.LevelEvent.READY_EVENTThis event is dispatched by the LevelManager when it is ready to be used.