Jump to content

Phaser YoYo tween question(SOLVED)


quiphop
 Share

Recommended Posts

Hi everyone. I'm stucked at tweens.
So, i have  yoyo tween. In first, i want to check that yoyo has reached it "middle" (before/on loop back), is there any way to check that?
The second question: at the docs we can see 

Quote

A tween that yoyos will reverse itself and play backwards automatically. A yoyo'd tween doesn't fire the Tween.onComplete event, so listen for Tween.onLoop instead

But, in my case the both methods will be called. Am i doing something wrong?

Here is my code : 

    this.p2AttackAnim = this.game.add.tween(this.p2).to({ x: 300 }, 500, Phaser.Easing.Bounce.Out, false, 0,0, true);
    
    this.p2AttackAnim.onStart.addOnce(function(){
      this.p2.frame = 2;
    }, this);
    
    this.p2AttackAnim.onComplete.addOnce(function(){
      this.p2.frame = 0;
      this.p1.frame = 1;
    }, this);
   
    this.p2AttackAnim.onLoop.addOnce(function(){
      this.p1.frame = 1;
    }, this);

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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