pixi-tween icon indicating copy to clipboard operation
pixi-tween copied to clipboard

Chained tweens are always added to manager

Open RanzQ opened this issue 9 years ago • 3 comments

I was wondering why the tween count in the manager was rising and noticed that when I was chaining non-expiring tweens, they were added to the manager every time on tween end.

https://github.com/Nazariglez/pixi-tween/blob/master/src/Tween.js#L169

So maybe it should be checked here if the tween has a manager already.

RanzQ avatar Jul 21 '16 18:07 RanzQ

Going to start using this lib... is this something I should look out for? Would it be a quick case of adding a check in the addTween function of TweenManager to see if the tween already exists in the array?

themoonrat avatar Jan 03 '17 18:01 themoonrat

Hi guys! Sorry I forgot to answer this.

Each tween created is added to the manager as a unique entity, this way allow store differents tweens in vars and contact them later.

Other way will be store a json object with the tween data and use only one instance of tween, chaining this "configs". But I don't see this clear, I think is easiest now.

Nazariglez avatar Jan 11 '17 17:01 Nazariglez

Finally came up against this issue - so I put a guard around adding to the manager. It now only does so if the tween wasn't already assigned to one - https://github.com/themoonrat/pixi-tween/commit/19400e7c17759821cf40480772d129c3231aea79#diff-6802f9302b04d546cb9ec4a1106ca6c0R189

themoonrat avatar Jan 25 '17 12:01 themoonrat