LogoPixi’VN
pixi-jsInterfaces

Interface: FindMixin

Defined in: node_modules/pixi.js/lib/scene/container/container-mixins/findMixin.d.ts:17

The FindMixin interface provides methods for finding children within a container by their label. It allows for searching for a single child or multiple children with a specific label, either directly or recursively through the container's hierarchy.

Advanced

Extends

  • Required<FindMixinConstructor>

Properties

label

> label: string

Defined in: node_modules/pixi.js/lib/scene/container/container-mixins/findMixin.d.ts:8

The instance label of the object.

Default

null

Inherited from

VideoSpriteMemory.label


~~name~~

> name: string

Defined in: node_modules/pixi.js/lib/scene/container/container-mixins/findMixin.d.ts:24

The instance name of the object.

Deprecated

since 8.0.0

See

Container#label

Default

null

Methods

getChildByLabel()

> getChildByLabel(label, deep?): Container<ContainerChild> | null

Defined in: node_modules/pixi.js/lib/scene/container/container-mixins/findMixin.d.ts:53

Returns the first child in the container with the specified label. Recursive searches are done in a pre-order traversal.

Parameters

label

string | RegExp

Instance label to search for

deep?

boolean

Whether to search recursively through children

Returns

Container<ContainerChild> | null

The first child with the specified label, or null if none found

Example

// Basic label search
const child = container.getChildByLabel('player');

// Search with regular expression
const enemy = container.getChildByLabel(/enemy-\d+/);

// Deep search through children
const deepChild = container.getChildByLabel('powerup', true);

See


~~getChildByName()~~

> getChildByName(label, deep?): Container<ContainerChild> | null

Defined in: node_modules/pixi.js/lib/scene/container/container-mixins/findMixin.d.ts:32

Parameters

label

string | RegExp

Instance name.

deep?

boolean

Whether to search recursively

Returns

Container<ContainerChild> | null

The child with the specified name.

Deprecated

since 8.0.0

See

Container#getChildByLabel


getChildrenByLabel()

> getChildrenByLabel(label, deep?, out?): Container<ContainerChild>[]

Defined in: node_modules/pixi.js/lib/scene/container/container-mixins/findMixin.d.ts:74

Returns all children in the container with the specified label. Recursive searches are done in a pre-order traversal.

Parameters

label

string | RegExp

Instance label to search for

deep?

boolean

Whether to search recursively through children

out?

Container<ContainerChild>[]

Optional array to store matching children in

Returns

Container<ContainerChild>[]

An array of children with the specified label

Example

// Basic label search
const enemies = container.getChildrenByLabel('enemy');
// Search with regular expression
const powerups = container.getChildrenByLabel(/powerup-\d+/);
// Deep search with collection
const buttons = [];
container.getChildrenByLabel('button', true, buttons);

See