mirror of
https://github.com/photonstorm/phaser
synced 2024-11-26 14:40:38 +00:00
You can now specify easeParams
for any custom easing function you wish to use. Fix #3826
This commit is contained in:
parent
4eb163573b
commit
aad9d38e13
2 changed files with 27 additions and 20 deletions
|
@ -20,6 +20,8 @@
|
|||
* `Tween.init` and `Tween.play` have been rewritten so they are not run multiple times when a Tween is paused before playback, or is part of a Timeline. This didn't cause any problems previously, but it was a redundant duplication of calls.
|
||||
* `Tween.onLoop` will now be invoked _after_ the `loopDelay` has expired, if any was set.
|
||||
* `Tween.onRepeat` will now be invoked _after_ the `repeatDelay` has expired, if any was set.
|
||||
* `easeParams` would be ignored for tweens that _didn't_ use a string for the ease function name. Fix #3826 (thanks @SBCGames)
|
||||
* You can now specify `easeParams` for any custom easing function you wish to use. Fix #3826 (thanks @SBCGames)
|
||||
|
||||
### New Features
|
||||
|
||||
|
|
|
@ -19,38 +19,43 @@ var EaseMap = require('../../math/easing/EaseMap');
|
|||
*/
|
||||
var GetEaseFunction = function (ease, easeParams)
|
||||
{
|
||||
// Default ease function
|
||||
var easeFunction = EaseMap.Power0;
|
||||
|
||||
// Prepare ease function
|
||||
if (typeof ease === 'string' && EaseMap.hasOwnProperty(ease))
|
||||
{
|
||||
if (easeParams)
|
||||
{
|
||||
var cloneParams = easeParams.slice(0);
|
||||
|
||||
cloneParams.unshift(0);
|
||||
|
||||
return function (v)
|
||||
{
|
||||
cloneParams[0] = v;
|
||||
|
||||
return EaseMap[ease].apply(this, cloneParams);
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
// String based look-up
|
||||
return EaseMap[ease];
|
||||
}
|
||||
easeFunction = EaseMap[ease];
|
||||
}
|
||||
else if (typeof ease === 'function')
|
||||
{
|
||||
// Custom function
|
||||
return ease;
|
||||
easeFunction = ease;
|
||||
}
|
||||
else if (Array.isArray(ease) && ease.length === 4)
|
||||
{
|
||||
// Bezier function (TODO)
|
||||
}
|
||||
|
||||
return EaseMap.Power0;
|
||||
// No custom ease parameters?
|
||||
if (!easeParams)
|
||||
{
|
||||
// Return ease function
|
||||
return easeFunction;
|
||||
}
|
||||
|
||||
var cloneParams = easeParams.slice(0);
|
||||
|
||||
cloneParams.unshift(0);
|
||||
|
||||
// Return ease function with custom ease parameters
|
||||
return function (v)
|
||||
{
|
||||
cloneParams[0] = v;
|
||||
|
||||
return easeFunction.apply(this, cloneParams);
|
||||
};
|
||||
};
|
||||
|
||||
module.exports = GetEaseFunction;
|
||||
|
|
Loading…
Reference in a new issue