Timer

Timer

Fires a color event on the board at a fixed interval, acting as a clock signal for other color-event-driven decorators.

Typical use: drive periodic effects such as toggling a DualTerrain or pulsing a ColorRelay — e.g. open and close a gate every 20 frames, or spawn an agent at regular intervals.

Constructor

new Timer(terrain, color, frames)

Source:
Parameters:
Name Type Description
terrain Terrain

The underlying terrain this decorator wraps.

color Color

The color event broadcast on each tick.

frames number

Interval in animation frames between firings. Values ≤ 0 are clamped to 1.

Extends

Classes

Timer

Members

terrain :Terrain

Source:
Overrides:
Type:

Methods

getProxiedTerrain()

Description:
  • Return the terrain being wrapped (TerrainProxy interface).

Source:
Overrides:

onFrame(_ctx, cell, frame)

Description:
  • Called by the AnimationManager on each animation tick. Fires the color event on the board whenever the frame counter is a positive multiple of Timer#_frames.

Source:
Parameters:
Name Type Description
_ctx CanvasRenderingContext2D

Unused.

cell Cell
frame number

Current animation frame counter.

proxy()

Description:
  • Returns a new Timer wrapping the given terrain, preserving color and interval.

Source: