Cocos Creator API

1.0.0

Cocos Creator is a highly customizable game development tool that utilizes the power of cocos2d-x.

pool

Module: cc

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...

Methods

putInPool
(
  • obj
)

Put the obj in pool.

name type description
obj Object

The need put in pool object.

examples:

---------------------------------
var sp = new _ccsg.Sprite("a.png");
this.addChild(sp);
cc.pool.putInPool(sp);
cc.pool.getFromPool(_ccsg.Sprite, "a.png");

hasObject
(
  • objClass
)
Boolean

Check if this kind of obj has already in pool.

name type description
objClass Object

The check object class.

returns:

type: Boolean

If this kind of obj is already in pool return true,else return false.

removeObject ( )

Remove the obj if you want to delete it.

getFromPool ( )

Get the obj from pool.

returns:

type:

Call the reuse function an return the obj.

drainAllPools ( )

Remove all objs in pool and reset the pool.

There are no methods that match your current filter settings. You can change your filter settings in the index section on this page. index