Jump to content

tween yoyo not working


Geoeo
 Share

Recommended Posts

Hello,

 

the following lines of code do not result in the tween being "yoyoed".

Am I missing something very simple?? :/

 

if(this.game.input.keyboard.isDown(Phaser.Keyboard.SPACEBAR)){this.game.add.tween(this.player.scale).to({x : 2.0, y : 2.0},300,Phaser.Easing.Linear.None,true,0,0,true);//                .to({x : 1.0, y : 1.0},300,Phaser.Easing.Linear.None,true,0,0,true)//                .start();        }

The commented out code is my dirty fix, but ideally I want to do it in one line.

 

 

Thanks

Link to comment
Share on other sites

Ok, so the yoyo effect only works when the penultimate arguments is non-zero. hmmm...

 

This works : 

this.game.add.tween(this.player.scale).to({x : 2.0, y : 2.0},300,Phaser.Easing.Linear.None,true,0,1,true);

Thanks Pedro!

 

Edit: Successive triggers of this tween i.e. hitting the space tab will make the sprite grow permanently. I.e. it does not revert back to scale 1.0.

Anybody have an idea why?

Link to comment
Share on other sites

  • 10 months later...

Edit: Successive triggers of this tween i.e. hitting the space tab will make the sprite grow permanently. I.e. it does not revert back to scale 1.0.

Anybody have an idea why?

 

The solution is to add the tween receiving the object's reference and then start the tween any time you want

// take a look at the autoStart = false parametervar myTween = this.game.add.tween(this.player.scale).to({x : 2.0, y : 2.0},300,Phaser.Easing.Linear.None,false,0,1,true);myTween.start();
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.

Guest
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.

Loading...
 Share

  • Recently Browsing   0 members

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