mobius3 / tweeny

A modern C++ tweening library
http://mobius3.github.io/tweeny
MIT License
742 stars 53 forks source link

how to get all Tweens in running? #9

Closed gamestarlsj closed 5 years ago

gamestarlsj commented 5 years ago

hello, thanks to you great lib. my Project need me to update tweens like this: https://github.com/sasq64/tween/blob/master/tween.cpp the Tween::updateTweens(double t) function can easier to step the all tweens, but now tweeny can't get all tween nodes like this. i thought i get all nodes in trouble . could you can help me to add new functions? thank you.

mobius3 commented 5 years ago

Hi, you need to hold a reference to your tweens manually and iterate on them manually as well. Tweeny has no mecanism to store created tweens, not yet at least.

You can store similarly typed tweens in the same container, like std::vector<tweeny::tween<int>> intTweens; and then you can iterate on them via for (auto && t : intTweens) t.step()

I hope this is what you are asking, I'm sorry if I misunderstood you.

gamestarlsj commented 5 years ago

thank you for you answering, finally i solved the question by add a vector to store them . i think sometimes the storage is necessary . in my project the timeline is global, with the timeline goes by ,tweeny need to update tweens in different files , so i defined the vector in tweeny.h , by std::vector<tweeny::tween<int>>. if @mobius3 haven't question you can close it .

mobius3 commented 5 years ago

I'm glad you could solve your problem!

If you're always iterating over the same number of values, you might consider using a multi-valued tween instead. For example:

auto tween = tweeny::from(0, 0, 0, 0, 0).to(10, 20, 30, 40, 50).during(100);

will create a single tween that iterates over those five values at the same time.

Should you have any more issues don't hesitate to ask!