Skip to content

Cannot persist a chain tween after stop #7048

Closed
@FranciscoCaetano88

Description

@FranciscoCaetano88

Version

  • Phaser Version: 3.88.2
  • Operating system: MacOsx
  • Browser:

Description

I expected that using the persist flag (true) on a chain tween would prevent it from being disposed of when stopped. The documentation mentions this behaviour, but I can't make it work.

Example Test Code

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

    preload()
    {
        this.load.setBaseURL('https://cdn.phaserfiles.com/v385');
        this.load.image('block', 'assets/sprites/block.png');
    }

    create()
    {
        var marker = this.add.image(100, 300, 'block').setAlpha(0.3);
        var image = this.add.image(100, 300, 'block');

        var tween = this.tweens.chain({
            paused: true,
            persist: true,
            tweens: [{
                targets: image,
                x: 700,
                delay: 1000,
                duration: 6000,
                ease: 'Power2'
            }]
        });

        var toggle = false;
        this.input.on('pointerdown', function () 
        {
            if (toggle) {
                tween.stop();
            } else {
                tween.play();
            }
            toggle = !toggle;
        });
    }
}

const config = {
    type: Phaser.AUTO,
    width: 800,
    height: 600,
    backgroundColor: '#2d2d2d',
    parent: 'phaser-example',
    scene: Example
};

const game = new Phaser.Game(config);

Additional Information

update function

Metadata

Metadata

Assignees

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