Package | com.joebillman.utils |
Class | public class ObjectPool |
Inheritance | ObjectPool ![]() |
Method | Defined By | ||
---|---|---|---|
ObjectPool(type:Class, amount:int, stopMCsOnCreation:Boolean = false, stopMCsOnDestruction:Boolean = false)
Constructor. | ObjectPool | ||
destroy():void
Destroys the objects array by setting it to null. | ObjectPool | ||
getAllObjects():Array
Gets a reference to the objects array. | ObjectPool | ||
getObject():DisplayObject
Gets an available item from the pool. | ObjectPool | ||
returnObject(obj:DisplayObject):void
Returns an item to the pool. | ObjectPool |
ObjectPool | () | Constructor |
public function ObjectPool(type:Class, amount:int, stopMCsOnCreation:Boolean = false, stopMCsOnDestruction:Boolean = false)
Constructor.
Parameterstype:Class | |
amount:int | |
stopMCsOnCreation:Boolean (default = false )
| |
stopMCsOnDestruction:Boolean (default = false )
|
destroy | () | method |
public function destroy():void
Destroys the objects array by setting it to null.
getAllObjects | () | method |
public function getAllObjects():Array
Gets a reference to the objects array. This is useful for performing individual item cleanup.
ReturnsArray —
|
getObject | () | method |
public function getObject():DisplayObject
Gets an available item from the pool.
ReturnsDisplayObject —
|
returnObject | () | method |
public function returnObject(obj:DisplayObject):void
Returns an item to the pool.
Parameters
obj:DisplayObject |
Note: Details
var enemyPool:ObjectPool = new ObjectPool(Enemy, 25);