ecspresso
    Preparing search index...

    Function createTimer

    • Create a one-shot timer that fires once after the specified duration.

      Parameters

      • duration: number

        Duration in seconds until the timer completes

      • Optionaloptions: TimerOptions

        Optional configuration including onComplete callback

      Returns Pick<TimerComponentTypes, "timer">

      Component object suitable for spreading into spawn()

      // Timer without callback
      ecs.spawn({
      ...createTimer(2),
      explosion: true,
      });

      // Timer with onComplete callback
      ecs.spawn({
      ...createTimer(1.5, { onComplete: (data) => console.log('done', data.entityId) }),
      });