Added Tween.restart and stopped the manager adding the same tween twice

This commit is contained in:
Richard Davey 2017-09-07 23:47:46 +01:00
parent a2d96f52e4
commit 206f6b1271
3 changed files with 15 additions and 1 deletions

View file

@ -160,6 +160,11 @@ var TweenManager = new Class({
makeActive: function (tween)
{
if (this._add.indexOf(tween) !== -1 || this._active.indexOf(tween) !== -1)
{
return;
}
var idx = this._pending.indexOf(tween);
if (idx !== -1)
@ -172,6 +177,8 @@ var TweenManager = new Class({
tween.state = TWEEN_CONST.PENDING_ADD;
this._toProcess++;
return this;
},
setGlobalTimeScale: require('./components/SetGlobalTimeScale'),

View file

@ -131,6 +131,12 @@ var Tween = new Class({
return this;
},
restart: function ()
{
this.stop();
this.play();
},
calcDuration: require('./components/CalcDuration'),
init: require('./components/Init'),
nextState: require('./components/NextState'),

View file

@ -10,6 +10,7 @@ var Play = function (resetFromTimeline)
{
this.init();
this.parent.makeActive(this);
resetFromTimeline = true;
}
var onStart = this.callbacks.onStart;
@ -46,7 +47,7 @@ var Play = function (resetFromTimeline)
}
else
{
this.resetTweenData(false);
this.resetTweenData(resetFromTimeline);
this.state = TWEEN_CONST.ACTIVE;