mirror of
https://github.com/photonstorm/phaser
synced 2024-11-16 17:58:23 +00:00
Added support for value interpolation
This commit is contained in:
parent
bec14fbac1
commit
e845dc207f
1 changed files with 17 additions and 5 deletions
|
@ -50,7 +50,7 @@ function hasGetters (def)
|
||||||
*
|
*
|
||||||
* A function can be provided to allow greater control over the end value; it will receive the target
|
* A function can be provided to allow greater control over the end value; it will receive the target
|
||||||
* object being tweened, the name of the property being tweened, and the current value of the property
|
* object being tweened, the name of the property being tweened, and the current value of the property
|
||||||
* as its arguments.
|
* as its arguments and must return a value.
|
||||||
*
|
*
|
||||||
* If both the starting and the ending values need to be controlled, an object with `getStart` and `getEnd`
|
* If both the starting and the ending values need to be controlled, an object with `getStart` and `getEnd`
|
||||||
* callbacks, which will receive the same arguments, can be provided instead. If an object with a `value`
|
* callbacks, which will receive the same arguments, can be provided instead. If an object with a `value`
|
||||||
|
@ -91,6 +91,18 @@ var GetValueOp = function (key, propertyValue)
|
||||||
return propertyValue;
|
return propertyValue;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
else if (Array.isArray(t))
|
||||||
|
{
|
||||||
|
// props: {
|
||||||
|
// x: [ 400, 300, 200 ],
|
||||||
|
// y: [ 10, 500, 10 ]
|
||||||
|
// }
|
||||||
|
|
||||||
|
getEnd = function (target, key, value, targetIndex, totalTargets, tween, tweenData)
|
||||||
|
{
|
||||||
|
return tweenData.interpolation(propertyValue, tweenData.progress);
|
||||||
|
};
|
||||||
|
}
|
||||||
else if (t === 'string')
|
else if (t === 'string')
|
||||||
{
|
{
|
||||||
// props: {
|
// props: {
|
||||||
|
@ -145,7 +157,7 @@ var GetValueOp = function (key, propertyValue)
|
||||||
// The same as setting just the getEnd function and no getStart
|
// The same as setting just the getEnd function and no getStart
|
||||||
|
|
||||||
// props: {
|
// props: {
|
||||||
// x: function (target, key, value, targetIndex, totalTargets, tween) { return value + 50); },
|
// x: function (target, key, value, targetIndex, totalTargets, tween, tweenData) { return value + 50); },
|
||||||
// }
|
// }
|
||||||
|
|
||||||
getEnd = propertyValue;
|
getEnd = propertyValue;
|
||||||
|
@ -157,19 +169,19 @@ var GetValueOp = function (key, propertyValue)
|
||||||
/*
|
/*
|
||||||
x: {
|
x: {
|
||||||
// Called the moment Tween is active. The returned value sets the property on the target immediately.
|
// Called the moment Tween is active. The returned value sets the property on the target immediately.
|
||||||
getActive: function (target, key, value, targetIndex, totalTargets, tween)
|
getActive: function (target, key, value, targetIndex, totalTargets, tween, tweenData)
|
||||||
{
|
{
|
||||||
return value;
|
return value;
|
||||||
},
|
},
|
||||||
|
|
||||||
// Called at the start of the Tween. The returned value sets what the property will be at the END of the Tween.
|
// Called at the start of the Tween. The returned value sets what the property will be at the END of the Tween.
|
||||||
getEnd: function (target, key, value, targetIndex, totalTargets, tween)
|
getEnd: function (target, key, value, targetIndex, totalTargets, tween, tweenData)
|
||||||
{
|
{
|
||||||
return value;
|
return value;
|
||||||
},
|
},
|
||||||
|
|
||||||
// Called at the end of the Tween. The returned value sets what the property will be at the START of the Tween.
|
// Called at the end of the Tween. The returned value sets what the property will be at the START of the Tween.
|
||||||
getStart: function (target, key, value, targetIndex, totalTargets, tween)
|
getStart: function (target, key, value, targetIndex, totalTargets, tween, tweenData)
|
||||||
{
|
{
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue