mirror of
https://github.com/photonstorm/phaser
synced 2024-11-24 13:43:26 +00:00
Added a Stepped ease.
This commit is contained in:
parent
c8b2c2bbb9
commit
bda588df02
4 changed files with 37 additions and 1 deletions
|
@ -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,
|
||||
|
|
|
@ -12,6 +12,7 @@ module.exports = {
|
|||
Quadratic: require('./quadratic'),
|
||||
Quartic: require('./quartic'),
|
||||
Quintic: require('./quintic'),
|
||||
Sine: require('./sine')
|
||||
Sine: require('./sine'),
|
||||
Stepped: require('./stepped')
|
||||
|
||||
};
|
||||
|
|
30
v3/src/math/easing/stepped/Stepped.js
Normal file
30
v3/src/math/easing/stepped/Stepped.js
Normal 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;
|
3
v3/src/math/easing/stepped/index.js
Normal file
3
v3/src/math/easing/stepped/index.js
Normal file
|
@ -0,0 +1,3 @@
|
|||
// Phaser.Math.Easing.Stepped
|
||||
|
||||
module.exports = require('./Stepped');
|
Loading…
Reference in a new issue