Skip to main content

Trap

Static

assignCallback

Assigns callbacks to each trap instance.

Trap.assignCallback(traps: array, callback: function) -> none

reached

Checks if each trap has hit the player.

Trap.reached(traps: array, pos: array) -> none

Methods

isActive

Returns true if the instance is active.

trap:isActive() -> boolean

reset

Resets the trap.

trap:reset() -> none

set

Set the traps to active.

trap:set() -> none

hitPlayer

Returns true if the trap hits the player.

trap:hitPlayer() -> boolean

setMovement

Sets the trap to be active for intervalLength, and delayed for delayLength.

trap:setMovement(intervalLength: number, delayLength: number) -> none

Properties

sprite

  • Type: sprite instance

Sprite to represent the trap.

timing

  • Type: object

The interval and delay times for the instance.

position

  • Type: array

Position of the instance on the canvas