Jump to content

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


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

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.

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.


  • Recently Browsing   0 members

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