Jump to content

Implicit passing of arguments to methods like Phaser.Easing.Quadratic.InOut?


ylluminarious
 Share

Recommended Posts

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

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

 Share

  • Recently Browsing   0 members

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