Skip to content

Adding an exsting TimerEvent to scene.time.addEvent() doesn't work #7314

Description

@unstoppablecarl

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:

  1. removeEvent(event) → pushes to _pendingRemoval
  2. Resets elapsed, repeatCount, etc. (but not the callback)
  3. Pushes to _pendingInsertion

Then in preUpdate:

  1. Removals run first → event.destroy() → callback = undefined
  2. 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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions