Skip to content

Commit 776e384

Browse files
committed
Merge pull request phaserjs#792 from codevinsky/tween-from
Phaser.Tween.from
2 parents 4466b3c + 224553e commit 776e384

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

src/tween/Tween.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,30 @@ Phaser.Tween.prototype = {
259259

260260
},
261261

262+
/**
263+
* Configure a Reverse Tween
264+
*
265+
* @method Phaser.Tween#from
266+
* @param {object} properties - Properties you want to tween from.
267+
* @param {number} [duration=1000] - Duration of this tween in ms.
268+
* @param {function} [ease=null] - Easing function. If not set it will default to Phaser.Easing.Linear.None.
269+
* @param {boolean} [autoStart=false] - Whether this tween will start automatically or not.
270+
* @param {number} [delay=0] - Delay before this tween will start, defaults to 0 (no delay). Value given is in ms.
271+
* @param {number} [repeat=0] - Should the tween automatically restart once complete? If you want it to run forever set as Number.MAX_VALUE. This ignores any chained tweens.
272+
* @param {boolean} [yoyo=false] - A tween that yoyos will reverse itself and play backwards automatically. A yoyo'd tween doesn't fire the Tween.onComplete event, so listen for Tween.onLoop instead.
273+
* @return {Phaser.Tween} This Tween object.
274+
*/
275+
from: function(properties, duration, ease, autoStart, delay, repeat, yoyo) {
276+
var _cache = {};
277+
for(var prop in properties) {
278+
if (properties.hasOwnProperty(prop)) {
279+
_cache[prop] = this._object[prop];
280+
this._object[prop] = properties[prop];
281+
}
282+
}
283+
this.to(_cache, duration, ease, autoStart, delay, repeat, yoyo);
284+
},
285+
262286
/**
263287
* Starts the tween running. Can also be called by the autoStart parameter of Tween.to.
264288
*

0 commit comments

Comments
 (0)