mirror of
https://github.com/photonstorm/phaser
synced 2024-11-27 15:12:18 +00:00
Added completeDelay and elasticity (not yet hooked up)
This commit is contained in:
parent
e2c08dd08e
commit
26591ce784
3 changed files with 21 additions and 18 deletions
|
@ -1,4 +1,4 @@
|
||||||
var CHECKSUM = {
|
var CHECKSUM = {
|
||||||
build: '48abf510-3ab5-11e7-94f8-f16a04e0b1e8'
|
build: '3f2f3a70-3ab9-11e7-9be9-3f1f4f292edc'
|
||||||
};
|
};
|
||||||
module.exports = CHECKSUM;
|
module.exports = CHECKSUM;
|
|
@ -13,24 +13,24 @@ var Tween = function (manager, target, key, value)
|
||||||
this.current;
|
this.current;
|
||||||
this.end;
|
this.end;
|
||||||
|
|
||||||
this.ease;
|
this.ease; // the ease function this tween uses
|
||||||
this.duration = 1000;
|
this.duration = 1000; // duration of the tween in ms/frames, excludes time for yoyo or repeats
|
||||||
this.yoyo = false;
|
this.yoyo = false; // alternate the tween back to its start position again?
|
||||||
this.repeat = 0;
|
this.repeat = 0; // number of times to repeat the tween (-1 = forever, same as setting loop=true)
|
||||||
this.loop = false;
|
this.loop = false; // infinitely loop this tween?
|
||||||
this.delay = 0;
|
this.delay = 0; // time in ms/frames between tween will start its first run
|
||||||
this.repeatDelay = 0;
|
this.repeatDelay = 0; // time in ms/frames before repeat will start
|
||||||
this.onCompleteDelay = 0;
|
this.onCompleteDelay = 0; // time in ms/frames before the 'onComplete' event fires
|
||||||
this.elasticity = 0;
|
this.elasticity = 0;
|
||||||
|
|
||||||
// Changes the property to be this before starting the tween
|
// Changes the property to be this before starting the tween
|
||||||
this.startAt;
|
this.startAt;
|
||||||
|
|
||||||
this.progress = 0;
|
this.progress = 0; // between 0 and 1 showing completion of current portion of tween
|
||||||
this.elapsed = 0;
|
this.elapsed = 0; // delta counter
|
||||||
this.countdown = 0;
|
this.countdown = 0; // delta countdown timer
|
||||||
|
|
||||||
this.repeatCounter = 0;
|
this.repeatCounter = 0; // how many repeats are left to run?
|
||||||
|
|
||||||
// 0 = Waiting to be added to the TweenManager
|
// 0 = Waiting to be added to the TweenManager
|
||||||
// 1 = Paused (dev needs to invoke Tween.start)
|
// 1 = Paused (dev needs to invoke Tween.start)
|
||||||
|
@ -141,7 +141,7 @@ Tween.prototype = {
|
||||||
|
|
||||||
var progress = elapsed / duration;
|
var progress = elapsed / duration;
|
||||||
|
|
||||||
var p = this.ease(progress);
|
var p = this.ease(progress, 0.1, this.elasticity);
|
||||||
|
|
||||||
// Optimize
|
// Optimize
|
||||||
this.current = this.start + ((this.end - this.start) * p);
|
this.current = this.start + ((this.end - this.start) * p);
|
||||||
|
@ -174,7 +174,7 @@ Tween.prototype = {
|
||||||
|
|
||||||
var progress = elapsed / duration;
|
var progress = elapsed / duration;
|
||||||
|
|
||||||
var p = this.ease(1 - progress);
|
var p = this.ease(1 - progress, 0.1, this.elasticity);
|
||||||
|
|
||||||
// Optimize
|
// Optimize
|
||||||
this.current = this.start + ((this.end - this.start) * p);
|
this.current = this.start + ((this.end - this.start) * p);
|
||||||
|
|
|
@ -151,11 +151,10 @@ var TweenBuilder = function (manager, config)
|
||||||
var yoyo = GetValue(config, 'yoyo', false);
|
var yoyo = GetValue(config, 'yoyo', false);
|
||||||
var repeat = GetAdvancedValue(config, 'repeat', 0);
|
var repeat = GetAdvancedValue(config, 'repeat', 0);
|
||||||
var repeatDelay = GetAdvancedValue(config, 'repeatDelay', 0);
|
var repeatDelay = GetAdvancedValue(config, 'repeatDelay', 0);
|
||||||
|
var completeDelay = GetAdvancedValue(config, 'completeDelay', 0);
|
||||||
var loop = GetValue(config, 'loop', false);
|
var loop = GetValue(config, 'loop', false);
|
||||||
var delay = GetAdvancedValue(config, 'delay', 0);
|
var delay = GetAdvancedValue(config, 'delay', 0);
|
||||||
|
var elasticity = GetAdvancedValue(config, 'elasticity', 0);
|
||||||
// var onCompleteDelay = 0;
|
|
||||||
// var elasticity = 0;
|
|
||||||
|
|
||||||
for (var p = 0; p < props.length; p++)
|
for (var p = 0; p < props.length; p++)
|
||||||
{
|
{
|
||||||
|
@ -168,8 +167,10 @@ var TweenBuilder = function (manager, config)
|
||||||
var iYoyo = GetValue(value, 'yoyo', yoyo);
|
var iYoyo = GetValue(value, 'yoyo', yoyo);
|
||||||
var iRepeat = GetAdvancedValue(value, 'repeat', repeat);
|
var iRepeat = GetAdvancedValue(value, 'repeat', repeat);
|
||||||
var iRepeatDelay = GetAdvancedValue(value, 'repeatDelay', repeatDelay);
|
var iRepeatDelay = GetAdvancedValue(value, 'repeatDelay', repeatDelay);
|
||||||
|
var iCompleteDelay = GetAdvancedValue(value, 'completeDelay', completeDelay);
|
||||||
var iLoop = GetValue(value, 'loop', loop);
|
var iLoop = GetValue(value, 'loop', loop);
|
||||||
var iDelay = GetAdvancedValue(value, 'delay', delay);
|
var iDelay = GetAdvancedValue(value, 'delay', delay);
|
||||||
|
var iElasticity = GetAdvancedValue(value, 'elasticity', elasticity);
|
||||||
|
|
||||||
for (var t = 0; t < targets.length; t++)
|
for (var t = 0; t < targets.length; t++)
|
||||||
{
|
{
|
||||||
|
@ -184,8 +185,10 @@ var TweenBuilder = function (manager, config)
|
||||||
tween.yoyo = iYoyo;
|
tween.yoyo = iYoyo;
|
||||||
tween.repeat = iRepeat;
|
tween.repeat = iRepeat;
|
||||||
tween.repeatDelay = iRepeatDelay;
|
tween.repeatDelay = iRepeatDelay;
|
||||||
|
tween.completeDelay = iCompleteDelay;
|
||||||
tween.loop = iLoop;
|
tween.loop = iLoop;
|
||||||
tween.delay = iDelay;
|
tween.delay = iDelay;
|
||||||
|
tween.elasticity = iElasticity;
|
||||||
|
|
||||||
tweens.push(tween);
|
tweens.push(tween);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue