mirror of
https://github.com/photonstorm/phaser
synced 2024-11-15 09:27:37 +00:00
Much more flexible in allowing the ease string input format
This commit is contained in:
parent
f792f13d7a
commit
594d75c26a
1 changed files with 42 additions and 2 deletions
|
@ -5,6 +5,7 @@
|
|||
*/
|
||||
|
||||
var EaseMap = require('../../math/easing/EaseMap');
|
||||
var UppercaseFirst = require('../../utils/string/UppercaseFirst');
|
||||
|
||||
/**
|
||||
* This internal function is used to return the correct ease function for a Tween.
|
||||
|
@ -25,10 +26,49 @@ var GetEaseFunction = function (ease, easeParams)
|
|||
var easeFunction = EaseMap.Power0;
|
||||
|
||||
// Prepare ease function
|
||||
if (typeof ease === 'string' && EaseMap.hasOwnProperty(ease))
|
||||
if (typeof ease === 'string')
|
||||
{
|
||||
// String based look-up
|
||||
easeFunction = EaseMap[ease];
|
||||
|
||||
// 1) They specified it correctly
|
||||
if (EaseMap.hasOwnProperty(ease))
|
||||
{
|
||||
easeFunction = EaseMap[ease];
|
||||
}
|
||||
else
|
||||
{
|
||||
// Do some string manipulation to try and find it
|
||||
var direction = '';
|
||||
|
||||
if (ease.indexOf('.'))
|
||||
{
|
||||
// quad.in = Quad.easeIn
|
||||
// quad.out = Quad.easeOut
|
||||
// quad.inout =Quad.easeInOut
|
||||
|
||||
direction = ease.substr(ease.indexOf('.') + 1);
|
||||
|
||||
if (direction.toLowerCase() === 'in')
|
||||
{
|
||||
direction = 'easeIn';
|
||||
}
|
||||
else if (direction.toLowerCase() === 'out')
|
||||
{
|
||||
direction = 'easeOut';
|
||||
}
|
||||
else if (direction.toLowerCase() === 'inout')
|
||||
{
|
||||
direction = 'easeInOut';
|
||||
}
|
||||
}
|
||||
|
||||
ease = UppercaseFirst(ease.substr(0, ease.indexOf('.') + 1) + direction);
|
||||
|
||||
if (EaseMap.hasOwnProperty(ease))
|
||||
{
|
||||
easeFunction = EaseMap[ease];
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (typeof ease === 'function')
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue