Added a Stepped ease.

This commit is contained in:
Richard Davey 2017-10-21 03:54:51 +01:00
parent c8b2c2bbb9
commit bda588df02
4 changed files with 37 additions and 1 deletions

View file

@ -9,6 +9,7 @@ var Quadratic = require('./quadratic');
var Quartic = require('./quartic');
var Quintic = require('./quintic');
var Sine = require('./sine');
var Stepped = require('./stepped');
// EaseMap
module.exports = {
@ -30,6 +31,7 @@ module.exports = {
Elastic: Elastic.Out,
Back: Back.Out,
Bounce: Bounce.Out,
Stepped: Stepped,
'Quad.easeIn': Quadratic.In,
'Cubic.easeIn': Cubic.In,

View file

@ -12,6 +12,7 @@ module.exports = {
Quadratic: require('./quadratic'),
Quartic: require('./quartic'),
Quintic: require('./quintic'),
Sine: require('./sine')
Sine: require('./sine'),
Stepped: require('./stepped')
};

View file

@ -0,0 +1,30 @@
/**
* [description]
*
* @function Phaser.Math.Easing.Stepped
* @since 3.0.0
*
* @param {number} v - [description]
* @param {float} [steps=1] - [description]
*
* @return {number} [description]
*/
var Stepped = function (v, steps)
{
if (steps === undefined) { steps = 1; }
if (v <= 0)
{
return 0;
}
else if (v >= 1)
{
return 1;
}
else
{
return (((steps * v) | 0) + 1) * (1 / steps);
}
};
module.exports = Stepped;

View file

@ -0,0 +1,3 @@
// Phaser.Math.Easing.Stepped
module.exports = require('./Stepped');