Juggler: Fixed pooled tweens not properly returned in pool when purging the juggler #1101
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hey Daniel,
Here is small fix regarding pooled tweens & juggler purging. Since the purge method was removing the objects without passing through an event, the pooled tweens weren't able to be released back to the pool.
Here I first try to remove the objects through events and then remove the remaining objects directly. This give a chance to the tween to get recycled.
I have also changed an event handler's name for better clarity.
Thanks in advance for your review & test.
Aurélien
Proposal for another PR
I would suggest to create another event
Event.REMOVED_FROM_JUGGLER
to indicate when an object is actually removed from the juggler (following the later refactoring, it's fairly simple to achieve). This would maybe simplify the situation. The pooled tweens could listen to this event instead. Here listening toEvent.REMOVE_FROM_JUGGLER
is a sort of override of a request for removal which is not super intuitive in my sense. This would also give a bit more flexibility for the users as well.