mirror of
https://github.com/photonstorm/phaser
synced 2024-11-10 15:14:47 +00:00
Tween.to now correctly accepts arrays are destination values, which makes the Tween interpolate through each value specified in the array using the defined Tween.interpolation method (see new example, thanks @FridayMarch26th #1619)
Tween.interpolationFunction was using the incorrect context to invoke the function. This is now defined in `TweenData.interpolationFunctionContext` and defaults to `Phaser.Math`. If you provide your own interpolation function then please adjust the context accordingly (thanks @FridayMarch26th #1618)
This commit is contained in:
parent
ae198e9364
commit
01a23b7d91
4 changed files with 35 additions and 19 deletions
|
@ -156,6 +156,8 @@ Thanks to @pnstickne for vast majority of this update.
|
|||
* PIXI.WebGLRenderer.destroy has been fixed to decrement the `glContextId` and remove it from the PIXI.instances global. `Game.destroy` now hooks into this. This now means that you can now delete and create your Phaser game over and over without it crashing WebGL after the 4th attempt (#1260)
|
||||
* World.setBounds if called after you had already started P2 Physics would incorrectly create a new collision group for the wall objects. P2.World now remembers the settings you provide for each wall and the collision group, and re-applies these settings should the world dimensions ever change (thanks @nextht #1455)
|
||||
* InputHandler was using the wrong property in `checkBoundsSprite` when fixedToCamera (thanks @yig #1613)
|
||||
* Tween.to now correctly accepts arrays are destination values, which makes the Tween interpolate through each value specified in the array using the defined Tween.interpolation method (see new example, thanks @FridayMarch26th #1619)
|
||||
* Tween.interpolationFunction was using the incorrect context to invoke the function. This is now defined in `TweenData.interpolationFunctionContext` and defaults to `Phaser.Math`. If you provide your own interpolation function then please adjust the context accordingly (thanks @FridayMarch26th #1618)
|
||||
|
||||
For changes in previous releases please see the extensive [Version History](https://github.com/photonstorm/phaser/blob/master/CHANGELOG.md).
|
||||
|
||||
|
|
|
@ -763,10 +763,11 @@ Phaser.Math = {
|
|||
|
||||
/**
|
||||
* A Linear Interpolation Method, mostly used by Phaser.Tween.
|
||||
*
|
||||
* @method Phaser.Math#linearInterpolation
|
||||
* @param {Array} v
|
||||
* @param {number} k
|
||||
* @return {number}
|
||||
* @param {Array} v - The input array of values to interpolate between.
|
||||
* @param {number} k - The percentage of interpolation, between 0 and 1.
|
||||
* @return {number} The interpolated value
|
||||
*/
|
||||
linearInterpolation: function (v, k) {
|
||||
|
||||
|
@ -790,10 +791,11 @@ Phaser.Math = {
|
|||
|
||||
/**
|
||||
* A Bezier Interpolation Method, mostly used by Phaser.Tween.
|
||||
*
|
||||
* @method Phaser.Math#bezierInterpolation
|
||||
* @param {Array} v
|
||||
* @param {number} k
|
||||
* @return {number}
|
||||
* @param {Array} v - The input array of values to interpolate between.
|
||||
* @param {number} k - The percentage of interpolation, between 0 and 1.
|
||||
* @return {number} The interpolated value
|
||||
*/
|
||||
bezierInterpolation: function (v, k) {
|
||||
|
||||
|
@ -811,10 +813,11 @@ Phaser.Math = {
|
|||
|
||||
/**
|
||||
* A Catmull Rom Interpolation Method, mostly used by Phaser.Tween.
|
||||
*
|
||||
* @method Phaser.Math#catmullRomInterpolation
|
||||
* @param {Array} v
|
||||
* @param {number} k
|
||||
* @return {number}
|
||||
* @param {Array} v - The input array of values to interpolate between.
|
||||
* @param {number} k - The percentage of interpolation, between 0 and 1.
|
||||
* @return {number} The interpolated value
|
||||
*/
|
||||
catmullRomInterpolation: function (v, k) {
|
||||
|
||||
|
@ -830,7 +833,6 @@ Phaser.Math = {
|
|||
}
|
||||
|
||||
return this.catmullRom(v[(i - 1 + m) % m], v[i], v[(i + 1) % m], v[(i + 2) % m], f - i);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -897,7 +899,7 @@ Phaser.Math = {
|
|||
},
|
||||
|
||||
/**
|
||||
* Calculates a callmum rom value.
|
||||
* Calculates a catmum rom value.
|
||||
*
|
||||
* @method Phaser.Math#catmullRom
|
||||
* @protected
|
||||
|
|
|
@ -177,7 +177,7 @@ Phaser.Tween.prototype = {
|
|||
* ".easeIn", ".easeOut" and "easeInOut" variants are all supported for all ease types.
|
||||
*
|
||||
* @method Phaser.Tween#to
|
||||
* @param {object} properties - An object containing the properties you want to tween., such as `Sprite.x` or `Sound.volume`. Given as a JavaScript object.
|
||||
* @param {object} properties - An object containing the properties you want to tween, such as `Sprite.x` or `Sound.volume`. Given as a JavaScript object.
|
||||
* @param {number} [duration=1000] - Duration of this tween in ms.
|
||||
* @param {function|string} [ease=null] - Easing function. If not set it will default to Phaser.Easing.Default, which is Phaser.Easing.Linear.None by default but can be over-ridden.
|
||||
* @param {boolean} [autoStart=false] - Set to `true` to allow this tween to start automatically. Otherwise call Tween.start().
|
||||
|
@ -496,11 +496,11 @@ Phaser.Tween.prototype = {
|
|||
* Sets the interpolation function the tween will use. By default it uses Phaser.Math.linearInterpolation.
|
||||
* Also available: Phaser.Math.bezierInterpolation and Phaser.Math.catmullRomInterpolation.
|
||||
* The interpolation function is only used if the target properties is an array.
|
||||
* If you have child tweens and pass -1 as the index value it sets the interpolation function across all of them.
|
||||
* If you have child tweens and pass -1 as the index value and it will set the interpolation function across all of them.
|
||||
*
|
||||
* @method Phaser.Tween#interpolation
|
||||
* @param {function} interpolation - The interpolation function to use (Phaser.Math.linearInterpolation by default)
|
||||
* @param {number} [index=0] - If this tween has more than one child this allows you to target a specific child. If set to -1 it will set the easing function on all children.
|
||||
* @param {number} [index=0] - If this tween has more than one child this allows you to target a specific child. If set to -1 it will set the interpolation function on all children.
|
||||
* @return {Phaser.Tween} This tween. Useful for method chaining.
|
||||
*/
|
||||
interpolation: function (interpolation, index) {
|
||||
|
|
|
@ -77,6 +77,12 @@ Phaser.TweenData = function (parent) {
|
|||
*/
|
||||
this.repeatDelay = 0;
|
||||
|
||||
/**
|
||||
* @property {boolean} interpolate - True if the Tween will use interpolation (i.e. is an Array to Array tween)
|
||||
* @default
|
||||
*/
|
||||
this.interpolate = false;
|
||||
|
||||
/**
|
||||
* @property {boolean} yoyo - True if the Tween is set to yoyo, otherwise false.
|
||||
* @default
|
||||
|
@ -117,6 +123,12 @@ Phaser.TweenData = function (parent) {
|
|||
*/
|
||||
this.interpolationFunction = Phaser.Math.linearInterpolation;
|
||||
|
||||
/**
|
||||
* @property {object} interpolationFunctionContext - The interpolation function context used for the Tween.
|
||||
* @default Phaser.Math
|
||||
*/
|
||||
this.interpolationFunctionContext = Phaser.Math;
|
||||
|
||||
/**
|
||||
* @property {boolean} isRunning - If the tween is running this is set to `true`. Unless Phaser.Tween a TweenData that is waiting for a delay to expire is *not* considered as running.
|
||||
* @default
|
||||
|
@ -273,7 +285,7 @@ Phaser.TweenData.prototype = {
|
|||
// Load the property from the parent object
|
||||
this.vStart[property] = this.parent.properties[property];
|
||||
|
||||
// Check if an Array was provided as property value (NEEDS TESTING)
|
||||
// Check if an Array was provided as property value
|
||||
if (Array.isArray(this.vEnd[property]))
|
||||
{
|
||||
if (this.vEnd[property].length === 0)
|
||||
|
@ -282,7 +294,7 @@ Phaser.TweenData.prototype = {
|
|||
}
|
||||
|
||||
// Create a local copy of the Array with the start value at the front
|
||||
this.vEnd[property] = [this.parent.properties[property]].concat(this.vEnd[property]);
|
||||
this.vEnd[property] = [this.vStart[property]].concat(this.vEnd[property]);
|
||||
}
|
||||
|
||||
if (typeof this.vEnd[property] !== 'undefined')
|
||||
|
@ -352,7 +364,7 @@ Phaser.TweenData.prototype = {
|
|||
|
||||
if (Array.isArray(end))
|
||||
{
|
||||
this.parent.target[property] = this.interpolationFunction(end, this.value);
|
||||
this.parent.target[property] = this.interpolationFunction.call(this.interpolationFunctionContext, end, this.value);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue