@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
Properties
overrideQueryEntities?
readonlyoptionaloverrideQueryEntities: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?
readonlyoptionalquery: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
Methods
create()
create(
data):ContainerChild
Defined in: src/rendering/sprite-creators/physicsEntitySpriteCreator.ts:40
Creates a sprite in the renderer.
Parameters
data
The data for creating the sprite for the entity.
Returns
ContainerChild
The created sprite
Overrides
delete()
delete(
__namedParameters,replacing):void
Defined in: src/rendering/sprite-creators/physicsEntitySpriteCreator.ts:122
Deletes a sprite from the renderer.
Parameters
__namedParameters
replacing
boolean
Returns
void
Overrides
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
emit()
emit(
event,data):void
Defined in: src/rendering/renderer.ts:264
Emits an event to all listeners.
Parameters
event
The event to emit.
data
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
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
The event to stop listening for.
callback?
The callback to stop listening for. If not provided, all listeners for the event will be removed.
Returns
void
Inherited from
on()
on(
event,callback):void
Defined in: src/rendering/renderer.ts:223
Adds a listener for the given event.
Parameters
event
The event to listen for.
callback
The callback to call when the event is fired.
Returns
void
Inherited from
update()
update(
data):void|ContainerChild
Defined in: src/rendering/sprite-creators/physicsEntitySpriteCreator.ts:96
Updates a sprite in the renderer.
Parameters
data
The data for updating the sprite for the entity.
Returns
void | ContainerChild
The new created sprite