| Package | com.joebillman.utils |
| Class | public class ObjectPool |
| Inheritance | ObjectPool Object |
| 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():voidDestroys the objects array by setting it to null.
| getAllObjects | () | method |
public function getAllObjects():ArrayGets a reference to the objects array. This is useful for performing individual item cleanup.
ReturnsArray —
|
| getObject | () | method |
public function getObject():DisplayObjectGets an available item from the pool.
ReturnsDisplayObject —
|
| returnObject | () | method |
public function returnObject(obj:DisplayObject):voidReturns an item to the pool.
Parameters
obj:DisplayObject |
Note: Details
var enemyPool:ObjectPool = new ObjectPool(Enemy, 25);