openfl / actuate

Actuate is a flexible, fast "tween" library for animations in Haxe
MIT License
158 stars 66 forks source link

I started a bunch of tweens in the same "for" and they are not synchronized #116

Open guifes opened 2 years ago

guifes commented 2 years ago

I would expect that any quantity of tweens started from the same "frame" would be always syncronized. But since SimpleActuator set the "startTime" var with:

Lib.getTimer()

every time a new tween is instantiated, each instance gets a slightly different time and thus get desynchronized from the others.

As a fix suggestion, maybe instead of lazily listening to Event.ENTER_FRAME, listen to it before any tweens are instantiated and keep a single value from Lib.getTimer() as startTime.

guifes commented 2 years ago

117 I've created a PR to fix this. Hope it helps. I think the PR version is better since, it guarantees that for all actuators instantiated in the same frame, they all get the same startTime, as already happens with "stage_onEnterFrame" that is called only once per frame and calls update on every actuators with the same "currentTime" instead of fetching a new Lib.getTimer() for each one.