fitness23

onComplete not triggering

3 posts in this topic

So I'm trying to create a tween within my sprite called "walkingTween".

enemy.walkingTween = this.game.add.tween(enemy).to({ x: this.player.x, y: this.player.y }, walkSpeedTime, Phaser.Easing.none).start();

And this successfully makes the tween happen.

However when I try to make it do something after the tween, onComplete doesn't trigger off.

enemy.walkingTween.onComplete.addOnce(function () {

                    console.log("Tween Complete!");
                }, this);

Any ideas?

 

If I did a normal tween such as:

var enemyWalk = this.game.add.tween(enemy).to({ x: this.player.x, y: this.player.y }, walkSpeedTime, Phaser.Easing.none).start();

Then the onComplete function DOES work. But for various reasons I have to have this tween assigned under the sprite itself.

Share this post


Link to post
Share on other sites

What you've posted seems to work fine in the sandbox, but without more context its hard to say what the problem might be. If you post a more complete sample of your code I can take a look. 

Share this post


Link to post
Share on other sites

Are you sure that the `onOnce` call is happening before the tween finishes?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.