Geoeo Posted May 4, 2014 Share Posted May 4, 2014 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 More sharing options...
Pedro Alpera Posted May 4, 2014 Share Posted May 4, 2014 Look at this example: http://examples.phaser.io/_site/view_full.html?d=tweens&f=yoyo.js&t=yoyo game.add.tween(sprite).to( { alpha: 1 }, 2000, Phaser.Easing.Linear.None, true, 0, 1000, true); Link to comment Share on other sites More sharing options...
Geoeo Posted May 4, 2014 Author Share Posted May 4, 2014 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 More sharing options...
Pedro Alpera Posted May 4, 2014 Share Posted May 4, 2014 I suppose the tweenings are cumulative, so successive triggers adds a new tween. It should be added only once. Link to comment Share on other sites More sharing options...
pctroll Posted April 2, 2015 Share Posted April 2, 2015 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 More sharing options...
Recommended Posts