ecspresso
    Preparing search index...

    Function createRepeatingTimer

    • Create a repeating timer that fires every duration seconds.

      Parameters

      • duration: number

        Duration in seconds between each timer completion

      • Optionaloptions: TimerOptions

        Optional configuration including onComplete callback

      Returns Pick<TimerComponentTypes, "timer">

      Component object suitable for spreading into spawn()

      // Timer without callback
      ecs.spawn({
      ...createRepeatingTimer(5),
      spawner: true,
      });

      // Repeating timer with onComplete callback
      ecs.spawn({
      ...createRepeatingTimer(3, { onComplete: (data) => console.log('cycle', data.elapsed) }),
      });