Cocos Creator API

1.1.1

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

NodePool

Module: cc

cc.NodePool is the cache pool designed for node type.
It can helps you to improve your game performance for objects which need frequent release and recreate operations

It's recommended to create cc.NodePool instances by node type, the type corresponds to node type in game design, not the class, for example, a prefab is a specific node type.
When you create a node pool, you can pass a Component which contains unuse, reuse functions to control the content of node.

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

Properties

poolHandlerComp Function | String

The pool handler component, it could be the class name or the constructor.

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

Methods

size ( )

The current available size in the pool

put ( )

Put a new Node into the pool. It will automatically remove the node from its parent without cleanup. It will also invoke unuse method of the poolHandlerComp if exist.

get ( ) Object | Null

Get a obj from pool, if no available object in pool, null will be returned. This function will invoke the reuse function of poolHandlerComp if exist.

returns:

type: Object | Null

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