• Pool 类型
    • 索引
      • 属性(properties)
      • 方法
  • Details
    • 属性(properties)
      • count
        • 参数列表
      • get
        • 参数列表
      • _get
      • put
      • resize

    Pool 类型

    模块: cc父模块: js

    长度固定的对象缓存池,可以用来缓存各种对象类型。这个对象池的实现非常精简,它可以帮助您提高游戏性能,适用于优化对象的反复创建和销毁。

    索引

    属性(properties)
    • count Number 当前可用对象数量,一开始默认是 0,随着对象的回收会逐渐增大,最大不会超过调用构造函数时指定的 size。
    方法
    • constructor 使用构造函数来创建一个指定对象类型的对象池,您可以传递一个回调函数,用于处理对象回收时的清理逻辑。
    • get 获取并初始化对象池中的对象。
    • _get 获取对象池中的对象,如果对象池没有可用对象,则返回空。
    • put 向对象池返还一个不再需要的对象。
    • resize 设置对象池容量。

    Details

    属性(properties)

    count
    当前可用对象数量,一开始默认是 0,随着对象的回收会逐渐增大,最大不会超过调用构造函数时指定的 size。
    metadescription
    类型Number
    定义于cocos2d/core/platform/js.js:928



    #### 方法



    ##### constructor


    使用构造函数来创建一个指定对象类型的对象池,您可以传递一个回调函数,用于处理对象回收时的清理逻辑。

    metadescription
    定义于cocos2d/core/platform/js.js:893
    参数列表
    • cleanupFunc Function the callback method used to process the cleanup logic when the object is recycled.
      • obj Object
    • size Number initializes the length of the array
    get

    获取并初始化对象池中的对象。这个方法默认为空,需要用户自己实现。

    metadescription
    返回Object
    定义于cocos2d/core/platform/js.js:918
    参数列表
    • params Any parameters to used to initialize the object
    _get

    获取对象池中的对象,如果对象池没有可用对象,则返回空。

    metadescription
    返回Object | Null
    定义于cocos2d/core/platform/js.js:938
    put

    向对象池返还一个不再需要的对象。

    metadescription
    定义于cocos2d/core/platform/js.js:956
    resize

    设置对象池容量。

    metadescription
    定义于cocos2d/core/platform/js.js:972