Class cc.pool
- Defined in: CCPool.js
Constructor Attributes | Constructor Name and Description |
---|---|
cc.pool()
cc.pool is a singleton object serves as an object cache pool. |
Method Summary
Class Detail
cc.pool()
cc.pool is a singleton object serves as an object cache pool.
It can helps you to improve your game performance for objects which need frequent release and recreate operations
Some common use case is :
1. Bullets in game (die very soon, massive creation and recreation, no side effect on other objects)
2. Blocks in candy crash (massive creation and recreation)
etc...
var sp = new cc.Sprite("a.png"); this.addChild(sp); cc.pool.putInPool(sp); cc.pool.getFromPool(cc.Sprite, "a.png");
Method Detail
-
drainAllPools()remove all objs in pool and reset the pool
-
{*} getFromPool(args)Get the obj from pool
- Parameters:
- args
- Returns:
- {*} call the reuse function an return the obj
-
{boolean} hasObject(objClass)Check if this kind of obj has already in pool
- Parameters:
- objClass
- Returns:
- {boolean} if this kind of obj is already in pool return true,else return false;
-
putInPool(obj)Put the obj in pool
- Parameters:
- obj
-
removeObject(obj)Remove the obj if you want to delete it;
- Parameters:
- obj