Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Canceling / destroying a tween collection #76

Closed
matthijskooijman opened this issue Mar 7, 2016 · 4 comments
Closed

Canceling / destroying a tween collection #76

matthijskooijman opened this issue Mar 7, 2016 · 4 comments

Comments

@matthijskooijman
Copy link

I have a number of related tweens which should run simultaneously and, sometimes, be canceled halfway collectively. I was hoping to use some kind of collection (GoTweenFlow seems promising) to manage these tweens, but AFAICS I can then only pause the tweens, not actually stop / destroy them through the collection. I would have to keep a separate list of tweens to call destroy() on, pretty much voiding the goal of the collection.

Am I missing something, or is this something that could/should be added?

@zapdot
Copy link

zapdot commented Mar 7, 2016

Do you only want a subset of the tweens that you put in the GoTweenFlow to
be cancelled/destroyed? Why not destroy the entire GoTweenFlow?

  • Michael

On Mon, Mar 7, 2016 at 4:41 AM, Matthijs Kooijman notifications@github.com
wrote:

I have a number of related tweens which should run simultaneously and,
sometimes, be canceled halfway collectively. I was hoping to use some kind
of collection (GoTweenFlow seems promising) to manage these tweens, but
AFAICS I can then only pause the tweens, not actually stop / destroy them
through the collection. I would have to keep a separate list of tweens to
call destroy() on, pretty much voiding the goal of the collection.

Am I missing something, or is this something that could/should be added?


Reply to this email directly or view it on GitHub
#76.

@matthijskooijman
Copy link
Author

No, I want to destroy them all. Looking at the code, GoTweenFlow does not override destroy(), so that would only make GoAbstractTweenCollection set its state to destroyed, not actually destroy the contained tweens. Though I haven't actually tested this, so I might have missed some bit of the code that makes this work, of course...

@zapdot
Copy link

zapdot commented Mar 7, 2016

So to answer your question, there's a bit of context to give:

The only thing GoKit does with tweens is keep them in a list to update them
every frame.

Whenever you set any AbstractGoTween (which includes GoTween, GoTweenChain
and GoTweenFlow), we just set an internal state in the tween to mark it as
destroyed.

When Go.cs is looping through all running tweens, it will remove that class
from the list of tweens to update every frame.

The reason why you don't need to worry about the internal list of Tweens
for the GoTweenFlow is because the collection keeps track of all those
internal tweens, not the master Go.cs class. Destroying the GoTweenFlow
effectively will destroy the other objects.

In short, whenever you want to remove all the tweens in a GoTweenFlow, just
call destroy() on the GoTweenFlow.

Hope this helps!

  • Michael

On Mon, Mar 7, 2016 at 12:33 PM, Matthijs Kooijman <notifications@github.com

wrote:

No, I want to destroy them all. Looking at the code, GoTweenFlow does not
override destroy(), so that would only make GoAbstractTweenCollection set
its state to destroyed, not actually destroy the contained tweens. Though I
haven't actually tested this, so I might have missed some bit of the
code that makes this work, of course...


Reply to this email directly or view it on GitHub
#76 (comment).

@matthijskooijman
Copy link
Author

Ah, I see. I was assuming that the other subclasses of AbstractGoTween would actually do something to remove themselves from the main list of running tweens in their destroy() methods, but that happens automatically by setting their state to destroyed, right.

Thanks for taking the time to explain, my doubts are answered! I should have just tried, instead of trying to figure out the code first :-p

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant