time-and-timers

Implement timers, delayed calls, and timeline event sequencing in Phaser 4 scenes.

Updated May 7, 2021
One-click install
npx skills add https://github.com/travispwingo/travispwingo.github.io --skill time-and-timers-travispwingo
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: time-and-timers
Source: https://github.com/travispwingo/travispwingo.github.io/tree/main/mario/docs/skills/time-and-timers
Command: npx skills add https://github.com/travispwingo/travispwingo.github.io --skill time-and-timers-travispwingo

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Scheduling time-based behavior in Phaser 4 games—delayed actions, repeating spawners, cooldowns, and choreographed cutscenes—requires correct use of the Clock plugin, TimerEvent, and Timeline APIs, where mistakes like off-by-one repeat counts or forgotten play() calls cause subtle bugs. ## Core Features & Use Cases - Timer Management: Create one-shot delayed calls, finite repeating timers, and infinite loops with this.time.addEvent and delayedCall, including pausing, removal, and per-timer time scaling. - Timeline Sequencing: Choreograph ordered events with absolute (at) or relative (from, in) timing, combining callbacks, tweens, sounds, property sets, and custom events for cutscenes. - Time Control: Apply slow motion or fast forward via Clock and Timeline timeScale, pause entire scenes of timers, and read progress with getRemaining and getOverallProgress. - Use Case: Build an enemy wave spawner that fires every 3 seconds, then a cutscene timeline that moves the player, plays a door sound, and emits a completion event before starting the next scene. ## Quick Start Ask the AI to create a Phaser 4 scene timer that spawns an enemy every 2 seconds and a timeline that plays a short intro cutscene.

Frequently Asked Questions about time-and-timers

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create a delayed call in Phaser 4?▼

Use this.time.delayedCall(delay, callback, args, scope) inside a scene to fire a one-shot callback after the given milliseconds. For repeating behavior, use this.time.addEvent with a delay and repeat or loop option instead.

How to make a repeating timer in Phaser?▼

Call this.time.addEvent with a config containing delay, callback, callbackScope, and either repeat for a finite count or loop: true for infinite repetition. Note that repeat: 4 produces 5 total callback fires, counting the initial invocation.

What is the difference between Phaser Timeline and TimerEvent?▼

TimerEvent is an independent timer managed by the scene Clock that fires callbacks on a delay. Timeline is a sequencer that schedules multiple events at absolute or relative times, supporting tweens, sounds, property sets, and custom events for cutscenes.

Why is my Phaser timeline not playing?▼

Timelines always start paused, so you must call timeline.play() after creating them with this.add.timeline. Also verify the scene is not paused, since Timeline updates are driven by the scene's update step.

Does Phaser timer timeScale affect timeline tweens?▼

No. Setting timeline.timeScale only scales the timeline's own elapsed counter; tweens spawned by the timeline run at their own speed. Set the tween's timeScale separately or control it through the TweenManager.

Why does my Phaser timer throw an infinite loop error?▼

A TimerEvent with delay: 0 combined with any repeat or loop setting throws 'TimerEvent infinite loop created via zero delay'. Use a non-zero delay, since a zero-delay repeating timer would fire every frame indefinitely.