Jump to content

Chained tweens and onComplete


GNUton
 Share

Recommended Posts

Hi, 

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.
        jumpTween.start();
 

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

 

Cheers,

Antonio

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

 Share

  • Recently Browsing   0 members

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