Skip to content

@emile/engine


@emile/engine / rendering/sprite-creators/physicsEntitySpriteCreator / PhysicsEntitySpriteCreator

Class: PhysicsEntitySpriteCreator

Defined in: src/rendering/sprite-creators/physicsEntitySpriteCreator.ts:15

A sprite creator.

Sprite creators are used to create, update and delete sprites in the renderer.

If the sprite creator update method returns a ContainerChild, delete will be called and the returned ContainerChild will replace the old one.

Warning

Your create and delete methods are responsible for adding/removing the sprite from the world container. The renderer will not do this for you.

Extends

Constructors

new PhysicsEntitySpriteCreator()

new PhysicsEntitySpriteCreator(defaultColor, defaultOpacity, zIndex, rigidbodyRadius, rigidbodyOpacity): PhysicsEntitySpriteCreator

Defined in: src/rendering/sprite-creators/physicsEntitySpriteCreator.ts:24

Parameters

defaultColor

ColorSource

defaultOpacity

number

zIndex

undefined | number

rigidbodyRadius

number = 0.1

rigidbodyOpacity

number = 0.5

Returns

PhysicsEntitySpriteCreator

Overrides

SpriteCreator.constructor

Properties

overrideQueryEntities?

readonly optional overrideQueryEntities: Set<string>

Defined in: src/rendering/renderer.ts:169

If set, this will override the query for this sprite creator.

Instead the sprite creator will run for all entities in this set.

This can also be useful for running a 'client only' sprite creator that doesn't use entities. You can instead fill the set with as many unique strings as you would like sprites. A good unique string would be Math.random().toString().substring(2, 15), this is almost guaranteed to be unique and not collide with any of your real entities.

DO NOT MODIFY THE SET AFTER CREATION.

Inherited from

SpriteCreator.overrideQueryEntities


query?

readonly optional query: EntityQuery

Defined in: src/rendering/renderer.ts:157

The query to match entities against.

The create, update and delete methods will only be called for entities that match this query.

If not set, the create, update and delete methods will be called for all entities.

Inherited from

SpriteCreator.query

Methods

create()

create(data): ContainerChild

Defined in: src/rendering/sprite-creators/physicsEntitySpriteCreator.ts:40

Creates a sprite in the renderer.

Parameters

data

SpriteCreatorData

The data for creating the sprite for the entity.

Returns

ContainerChild

The created sprite

Overrides

SpriteCreator.create


delete()

delete(__namedParameters, replacing): void

Defined in: src/rendering/sprite-creators/physicsEntitySpriteCreator.ts:122

Deletes a sprite from the renderer.

Parameters

__namedParameters

SpriteCreatorData

replacing

boolean

Returns

void

Overrides

SpriteCreator.delete


dispose()

dispose(): void

Defined in: src/rendering/sprite-creators/physicsEntitySpriteCreator.ts:131

Dispose of the sprite creator.

Can be used to clean up any resources used by the sprite creator.

Called when the renderer is disposed.

Returns

void

Overrides

SpriteCreator.dispose


emit()

emit(event, data): void

Defined in: src/rendering/renderer.ts:264

Emits an event to all listeners.

Parameters

event

SpriteCreatorEventType

The event to emit.

data

SpriteCreatorData

The data to pass to the listeners.

Returns

void

Note

You don't need to call this method yourself unless you want to emit custom events. The renderer will automatically emit the CREATE, UPDATE, DELETE and DISPOSE events at the appropriate times.

Inherited from

SpriteCreator.emit


off()

off(event, callback?): void

Defined in: src/rendering/renderer.ts:239

Removes a listener for the given event.

If no callback is provided, all listeners for the event will be removed.

Parameters

event

SpriteCreatorEventType

The event to stop listening for.

callback?

SpriteCreatorEventCallback

The callback to stop listening for. If not provided, all listeners for the event will be removed.

Returns

void

Inherited from

SpriteCreator.off


on()

on(event, callback): void

Defined in: src/rendering/renderer.ts:223

Adds a listener for the given event.

Parameters

event

SpriteCreatorEventType

The event to listen for.

callback

SpriteCreatorEventCallback

The callback to call when the event is fired.

Returns

void

Inherited from

SpriteCreator.on


update()

update(data): void | ContainerChild

Defined in: src/rendering/sprite-creators/physicsEntitySpriteCreator.ts:96

Updates a sprite in the renderer.

Parameters

data

SpriteCreatorData

The data for updating the sprite for the entity.

Returns

void | ContainerChild

The new created sprite

Overrides

SpriteCreator.update