ylluminarious Posted July 2, 2015 Share Posted July 2, 2015 Hi all, I was looking at using tweens in a simple application, and something struck me as odd when using `game.add.tween.to`. By looking at examples like this, it looks like you can pass in the easing function without specifying any arguments for it. E.g.,game.add.tween(purpleFish).to({ x: -200 }, 7500, Phaser.Easing.Quadratic.InOut, true, 0, 1000, false);Reading from the docs, methods like Phaser.Easing.Quadratic.InOut need arguments to be passed in or they'll return NaN. However, the code above works fine without any arguments getting passed in to Phaser.Easing.Quadratic.InOut. Is something going on here internally that passes in those arguments for you? Link to comment Share on other sites More sharing options...
Account Deleted Posted July 2, 2015 Share Posted July 2, 2015 This required some digging, but in phaser the value needed to be passed to Quadratic.InOut is the value k, which happens to end up being the value this.percent in Phaser.TweenData#update Now this value this.percent is based off of this.dt / this.duration (and you set duration in your example of 7500. ) Lets say we have no idea what this.dt is but we have a duration. 0 / 7500 = 0. Ergo as long as there is a duration it'll always equal to 0 instead of NaN. Link to comment Share on other sites More sharing options...
ylluminarious Posted July 2, 2015 Author Share Posted July 2, 2015 Thanks, you're right. I was doing something else wrong; it actually doesn't return NaN. Account Deleted 1 Link to comment Share on other sites More sharing options...
Recommended Posts