Added completeDelay and elasticity (not yet hooked up)

This commit is contained in:
Richard Davey 2017-05-17 05:52:01 +01:00
parent e2c08dd08e
commit 26591ce784
3 changed files with 21 additions and 18 deletions

View file

@ -1,4 +1,4 @@
var CHECKSUM = {
build: '48abf510-3ab5-11e7-94f8-f16a04e0b1e8'
build: '3f2f3a70-3ab9-11e7-9be9-3f1f4f292edc'
};
module.exports = CHECKSUM;

View file

@ -13,24 +13,24 @@ var Tween = function (manager, target, key, value)
this.current;
this.end;
this.ease;
this.duration = 1000;
this.yoyo = false;
this.repeat = 0;
this.loop = false;
this.delay = 0;
this.repeatDelay = 0;
this.onCompleteDelay = 0;
this.ease; // the ease function this tween uses
this.duration = 1000; // duration of the tween in ms/frames, excludes time for yoyo or repeats
this.yoyo = false; // alternate the tween back to its start position again?
this.repeat = 0; // number of times to repeat the tween (-1 = forever, same as setting loop=true)
this.loop = false; // infinitely loop this tween?
this.delay = 0; // time in ms/frames between tween will start its first run
this.repeatDelay = 0; // time in ms/frames before repeat will start
this.onCompleteDelay = 0; // time in ms/frames before the 'onComplete' event fires
this.elasticity = 0;
// Changes the property to be this before starting the tween
this.startAt;
this.progress = 0;
this.elapsed = 0;
this.countdown = 0;
this.progress = 0; // between 0 and 1 showing completion of current portion of tween
this.elapsed = 0; // delta counter
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
// 1 = Paused (dev needs to invoke Tween.start)
@ -141,7 +141,7 @@ Tween.prototype = {
var progress = elapsed / duration;
var p = this.ease(progress);
var p = this.ease(progress, 0.1, this.elasticity);
// Optimize
this.current = this.start + ((this.end - this.start) * p);
@ -174,7 +174,7 @@ Tween.prototype = {
var progress = elapsed / duration;
var p = this.ease(1 - progress);
var p = this.ease(1 - progress, 0.1, this.elasticity);
// Optimize
this.current = this.start + ((this.end - this.start) * p);

View file

@ -151,11 +151,10 @@ var TweenBuilder = function (manager, config)
var yoyo = GetValue(config, 'yoyo', false);
var repeat = GetAdvancedValue(config, 'repeat', 0);
var repeatDelay = GetAdvancedValue(config, 'repeatDelay', 0);
var completeDelay = GetAdvancedValue(config, 'completeDelay', 0);
var loop = GetValue(config, 'loop', false);
var delay = GetAdvancedValue(config, 'delay', 0);
// var onCompleteDelay = 0;
// var elasticity = 0;
var elasticity = GetAdvancedValue(config, 'elasticity', 0);
for (var p = 0; p < props.length; p++)
{
@ -168,8 +167,10 @@ var TweenBuilder = function (manager, config)
var iYoyo = GetValue(value, 'yoyo', yoyo);
var iRepeat = GetAdvancedValue(value, 'repeat', repeat);
var iRepeatDelay = GetAdvancedValue(value, 'repeatDelay', repeatDelay);
var iCompleteDelay = GetAdvancedValue(value, 'completeDelay', completeDelay);
var iLoop = GetValue(value, 'loop', loop);
var iDelay = GetAdvancedValue(value, 'delay', delay);
var iElasticity = GetAdvancedValue(value, 'elasticity', elasticity);
for (var t = 0; t < targets.length; t++)
{
@ -184,8 +185,10 @@ var TweenBuilder = function (manager, config)
tween.yoyo = iYoyo;
tween.repeat = iRepeat;
tween.repeatDelay = iRepeatDelay;
tween.completeDelay = iCompleteDelay;
tween.loop = iLoop;
tween.delay = iDelay;
tween.elasticity = iElasticity;
tweens.push(tween);