Skip to content

API / BaseObject

Class: abstract BaseObject ​

Defined in: core/BaseObject.ts:33

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.

Extended by ​

Constructors ​

Constructor ​

ts
new BaseObject(): BaseObject;

Returns ​

BaseObject

Properties ​

hashCode ​

ts
readonly hashCode: number;

Defined in: core/BaseObject.ts:156

A unique identification number assigned to the object.

Methods ​

returnToPool() ​

ts
returnToPool(): void;

Defined in: core/BaseObject.ts:167

Clear the object and return it back to object pool。

Returns ​

void


borrowObject() ​

ts
static borrowObject<T>(objectConstructor: () => T): T;

Defined in: core/BaseObject.ts:136

Get an instance of the specify class from object pool.

Type Parameters ​

Type Parameter
T extends BaseObject

Parameters ​

ParameterTypeDescription
objectConstructor() => TThe specify class.

Returns ​

T


clearPool() ​

ts
static clearPool(objectConstructor: typeof BaseObject): void;

Defined in: core/BaseObject.ts:111

Clear the cached instances of a specify object pool.

Parameters ​

ParameterTypeDefault valueDescription
objectConstructortypeof BaseObjectnullSpecify class. (Clear all cached instances if not set)

Returns ​

void


setMaxCount() ​

ts
static setMaxCount(objectConstructor: typeof BaseObject, maxCount: number): void;

Defined in: core/BaseObject.ts:72

Set the maximum cache count of the specify object pool.

Parameters ​

ParameterTypeDescription
objectConstructortypeof BaseObjectThe specify class. (Set all object pools max cache count if not set)
maxCountnumberMax count.

Returns ​

void


toString() ​

ts
static toString(): string;

Defined in: core/BaseObject.ts:56

Returns ​

string

Released under the MIT License.