time-and-timers

Featured

Use this skill when using timers and time-based events in Phaser 4. Covers TimerEvent, delayed calls, looping timers, the Clock plugin, and time scaling. Triggers on: timer, delay, delayedCall, TimerEvent, Clock, time event.

AI & Automation 957 stars 79 forks Updated today MIT

Install

View on GitHub

Quality Score: 93/100

Stars 20%
99
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# Time and Timers > Clock plugin, TimerEvent, delays, loops, Timeline event sequencing, pausing time, time scale, and delta time in Phaser 4. **Key source paths:** `src/time/Clock.js`, `src/time/TimerEvent.js`, `src/time/Timeline.js`, `src/time/typedefs/`, `src/time/events/` **Related skills:** ../scenes/SKILL.md, ../tweens/SKILL.md ## Quick Start ```js // In a Scene's create() method: // One-shot delayed call (fires once after 1 second) this.time.delayedCall(1000, () => { console.log('One second later'); }); // Repeating timer (fires 5 times, once every 500ms) this.time.addEvent({ delay: 500, callback: () => { console.log('tick'); }, repeat: 4 // 4 repeats = 5 total fires }); // Infinite loop timer this.time.addEvent({ delay: 1000, callback: this.spawnEnemy, callbackScope: this, loop: true }); ``` `this.time` is the scene's `Clock` instance (registered as the `'Clock'` plugin under the key `time`). It creates and manages `TimerEvent` objects that fire callbacks based on game time. ## Core Concepts ### Clock (this.time) The Clock is a Scene-level plugin that tracks game time and updates all of its TimerEvents each frame. Key properties: - **`now`** -- current time in ms (equivalent to `time` passed to the scene `update` method). - **`startTime`** -- timestamp when the scene started. - **`timeScale`** -- multiplier applied to delta time. Default `1`. Values above 1 speed up all timers; below 1 slow them down; `0` freezes time. - **`...

Details

Author
autonomous-ai
Repository
autonomous-ai/openharness
Created
1 months ago
Last Updated
today
Language
C
License
MIT

Similar Skills

Semantically similar based on skill content — not just same category