Yes, that's what I'm trying to do. Stable animation without chaotic changes.
Yeah, that helped, animation is synced during the game even if I switch tabs, it's great! But when I use recursive delayedCall as setInterval, I have little problem: using delayedCall is not accurate enough. I rarely have problem when delayedCall with 1s delay is invoked faster then 5th recursive invocation of delayedCall with 199.4ms delay (summary 997ms). Of course it's not a problem of delayedCall, it's just because it tooks some time to run code before next delayedCall invocation. Now I'm trying to rearchitect calculation logic according to delayedCall feature. But it would be easier if TweenMax had direct functionality for setInterval or at least functionality to cancel upcoming delayedCall like clearTimeout/clearInterval.
Also I found some bug with creating new TweenMax object. I thought that this is a sync problem too, but I found that this is another problem. Rarely and randomly when running this code:
animateStick: function ($stick) {
var _this = this;
var translateYValue = this.windowHeight + -this.stickTop;
var tween = new TweenMax($stick, this.stickDuration, {
y: translateYValue, ease: Power0.easeNone, onComplete: function () {
$stick.remove();
_this.stickTweensArray.shift();
}
});
console.log(tween);
_this.stickTweensArray.push({tween:tween, $stick:$stick});
}
wrong tween creates with next properties:
_active: false (when correct tweens have true);
_dirty: true (when correct tweens have false);
_propLookup: Array[0] (when correct tweens have Array[1] with y:Object inside);
_startTime: NaN;
matrix(1, 0, 0, 1, 0, 0) (when correct tweens have matrix(1, 0, 0, 1, 0, y(t));
also this wrong tween has less properties than the correct one.
I thought may be my code is wrong and object $stick is wrong, but I checked it in debug and everything is fine with $stick. The bug is reproduced more often when the game goes faster. This bug is critical enough for me, so I hope you can help me with that.
PS. You can observe this bug even in sample that i posted before, but very rarely (mb once or twice per run) and only almost at top speed (after 40s of running)
http://codepen.io/anon/pen/xgZMVd/