phaserjs / phaserjs/phaser

Timeline's complete event is triggered prematurely before tweens finish

Open
#7,159 3 comments 0 reactions 0 assignees View on GitHub

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: 3.90.0
  • Operating System: macOS

Description

The Timeline's complete event is triggered before all its tweens have completed.

Example Test Code

class Example extends Phaser.Scene {
    constructor() {
        super();
    }

    preload() {}

    create() {
        const timeline = this.add.timeline();

        const counter = {
            x: 0
        };

        timeline.add({
            at: 0,
            run: () => {
                console.log("Start!");
            }
        });

        timeline.add({
            at: 100,
            tween: {
                targets: counter,
                duration: 3000,
                x: 1000,
                onComplete: () => {
                    console.log("Tween complete: counter.x =", counter.x);
                }
            }
        });

        timeline.on("complete", () => {
            console.log("Timeline complete: counter.x =", counter.x);
        });

        timeline.play();
    }
}

const game = new Phaser.Game({
    type: Phaser.WEBGL,
    parent: 'phaser-example',
    width: 800,
    height: 800,
    scene: Example
});

Expected Behavior

The Timeline's complete event should only be triggered after all tweens within the timeline have completed.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the JavaScript example from the issue and compare the logged order and counter.x values. Trace the Phaser Timeline completion behavior around the tween, then verify that the Timeline complete event fires only after the tween's onComplete callback and final value are reached.

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
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.