Jump to content

Chained tweens and onComplete


Recommended Posts


I would like to know what's the best way to trigger my function with chained tweens.

The following code doesn't really work. The function which contains the "alert" is triggered when the first tween completes.


var jumpTween = game.add.tween(playState.player);
        jumpTween.to({ y: 70 }, 200);
        ju empTween.to({ y: 150}, 400);
        jumpTween.onComplete.add(function(){console.log("CIAO");}, this);  <--- This is triggered when y=70.

Is there any elegant solution which doesn't involves combined tweens? (http://examples.phaser.io/_site/view_full.html?d=tweens&f=combined+tweens.js&t=combined%20tweens




Link to comment
Share on other sites

The linked _lastChild solution works perfectly - but I wish there was official API to do it.


@Rich, maybe you could create a getLastTween function that (for now) returns _lastChild?


Because anything beginning with underscore is to be considered private and should not be accessed from outside the lib.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...