Initialize Trigger object.
The hitbox to use for the trigger.
Callback used when the trigger area is entered.
Callback used when the trigger area is exited.
Whether to display a debug rectangle for the trigger.
The opacity of the entity (from 0 to 1)
An array of child entities for recursive update/render.
Whether or not the entity is dead.
The hitbox of the sprite.
Position of the entity.
The rotation of the sprite.
Scale of the entity.
Whether or not the entity is visible.
Gets the anchor point.
Sets the debug state.
Whether or not there are any child entities.
Gets the height of the sprite in pixels, accounting for scale.
Sets the height.
Gets the pivot point (used for rotations).
Gets the texture.
Gets the width of the sprite in pixels, accounting for scale.
Sets the width.
Add and return a child object.
Object to add to the container.
Call to trigger onEnter callback.
Call to trigger onExit callback.
Remove and return a child object.
Object to remove from the container.
Empty implementation from extending Entity.
Not used.
Not used.
An area that invokes callbacks when an object enters and/or exits (as determined by collision check).
Example
const door = new Trigger( new HitBox(0, 0, 10, 10), () => { console.log('Trigger entered.') }, () => { console.log('Trigger exited.') } ) // In collision checks. // Sprite collides, call onEnter if first time. if (sprite.hit(player, door)) { if (doorEntered) { return } doorEntered = true door.onEnter() return } // Sprite does not collide, call onExit if previously entered. if (doorEntered) { doorEntered = false door.onExit() }