Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

calling tween.play() again makes tween state bug #4184

Closed
SamCode opened this issue Nov 22, 2018 · 1 comment
Closed

calling tween.play() again makes tween state bug #4184

SamCode opened this issue Nov 22, 2018 · 1 comment

Comments

@SamCode
Copy link

SamCode commented Nov 22, 2018

Version

  • Phaser Version: 3.15.1
  • Operating system: Windows 10
  • Browser: Google Chrome

Description

When tween.play() is called a second time, the expected behavior is for the tween's state to reset so the tween can play again, OR tween.state === Phaser.Tweens.COMPLETE.

What actually happens is two semantic inconsistencies:

  1. after one call of tween.play(), tween.state === Phaser.Tweens.REMOVED instead of Phaser.Tweens.COMPLETE
  2. then jumps to Phaser.Tweens.ACTIVE and tween.isPlaying() returns true indefinitely, while the tween does not actually ever update.

Example Test Code

  1. https://labs.phaser.io/edit.html?src=src/tweens/update%20to.js
  2. example code in scene.create()
var tween = this.tweens.create({
    targets: [ sprite ],
    alpha: 0.5,
    ease: Phaser.Math.Easing.Sine.Out,
    duration: 200,
    yoyo: true,
    repeat: 0
});

sprite.setInteractive();
sprite.on('pointerdown', function(pointer) {
    // fails on second attempt
    tween.play();

    // always true
    console.log(tween.isPlaying());
});

Additional Information

Currently, this hack seems to patch the issue, but is not an intuitive way to handle tweens.

if (tween.state === Phaser.Tweens.REMOVED) {
    tween.restart();
    this.tweens.existing(tween);
} else {
    tween.play(true);
}

If I have a reference to a tween, I would like to use it freely without having to modify both the tween and the tween manager.

@SamCode SamCode changed the title tween.state === ACTIVE indefinitely without ever updating calling tween.play() again makes tween state bug Nov 22, 2018
@photonstorm
Copy link
Collaborator

Thank you for submitting this issue. We have fixed this and the fix has been pushed to the master branch. It will be part of the next release. If you get time to build and test it for yourself we would appreciate that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants