Adding an exsting TimerEvent to scene.time.addEvent() doesn't work
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 40.3k
- Forks
- 7.2k
- PR merge metrics
- No merged PRs in 30d
Description
Version
- Phaser Version: 4.1.0
Description
In the scene.time.addEvent(instance) path. The intent looks like it would remove from wherever it currently is, reset it, re-add it. But the implementation sequences it incorrectly:
- removeEvent(event) → pushes to _pendingRemoval
- Resets elapsed, repeatCount, etc. (but not the callback)
- Pushes to _pendingInsertion
Then in preUpdate:
- Removals run first → event.destroy() → callback = undefined
- Insertions run second → event added to _active with no callback
This breaks for any existing instance, including timers already running in _active. The destroy wipes the callback before the re-insertion, so the timer advances normally but fires nothing.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the scene.time.addEvent(instance) path and follow its interaction with removeEvent and preUpdate, including the _pendingRemoval, _pendingInsertion, and _active queues. Verify the existing TimerEvent can be re-added without losing its callback, and confirm that the timer advances and fires its callback after reinsertion.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- game-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100