pixi-dragonbones-runtime
Version:
DragonBones Runtime for Pixi.js
96 lines (95 loc) • 3.87 kB
TypeScript
/**
* The MIT License (MIT)
*
* Copyright (c) 2012-2018 DragonBones team and other contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/**
* [en] The BaseObject is the base class for all objects in the DragonBones framework.
* All BaseObject instances are cached to the object pool to reduce the performance consumption of frequent requests for memory or memory recovery.
*
* [zh] 基础对象,通常 DragonBones 的对象都继承自该类。
* 所有基础对象的实例都会缓存到对象池,以减少频繁申请内存或内存回收的性能消耗。
*
* @version DragonBones 4.5
*/
export declare abstract class BaseObject {
private static _hashCode;
private static _defaultMaxCount;
private static readonly _maxCountMap;
private static readonly _poolsMap;
private static _returnObject;
static toString(): string;
/**
* [en] Set the maximum cache count of the specify object pool.
*
* [zh] 设置特定对象池的最大缓存数量。
*
* @param objectConstructor - [en] The specify class. (Set all object pools max cache count if not set)
* @param objectConstructor - [zh] 特定的类。 (不设置则设置所有对象池的最大缓存数量)
*
* @param maxCount - [en] Max count.
* @param maxCount - [zh] 最大缓存数量。
*
* @version DragonBones 4.5
*/
static setMaxCount(objectConstructor: (typeof BaseObject) | null, maxCount: number): void;
/**
* [en] Clear the cached instances of a specify object pool.
*
* [zh] 清除特定对象池的缓存实例。
*
* @param objectConstructor - [en] Specify class. (Clear all cached instances if not set)
* @param objectConstructor - [zh] 特定的类。 (不设置则清除所有缓存的实例)
*
* @version DragonBones 4.5
*/
static clearPool(objectConstructor?: (typeof BaseObject) | null): void;
/**
* [en] Get an instance of the specify class from object pool.
*
* [zh] 从对象池中获取特定类的实例。
*
* @param objectConstructor - [en] The specify class.
* @param objectConstructor - [zh] 特定的类。
*
* @version DragonBones 4.5
*/
static borrowObject<T extends BaseObject>(objectConstructor: {
new (): T;
}): T;
/**
* [en] A unique identification number assigned to the object.
*
* [zh] 分配给此实例的唯一标识号。
*
* @version DragonBones 4.5
*/
readonly hashCode: number;
private _isInPool;
protected abstract _onClear(): void;
/**
* [en] Clear the object and return it back to object pool。
*
* [zh] 清除该实例的所有数据并将其返还对象池。
*
* @version DragonBones 4.5
*/
returnToPool(): void;
}