-
Notifications
You must be signed in to change notification settings - Fork 458
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
FlxTween#cancelTweensOf(), closes #1458 #1495
Conversation
for when an object is destroyed before any dependent tweens are completed.
You have to manually call the functions. Better for performance than automatically doing it.
Static methods and compile fixes
Looks useful, but at the same time it seems like a somewhat awkward workaround for tweens not being added to |
Yeah @Beeblerox said this would be part of a refactor later on. I need the functionality now, and I figured I'd post how I did it. |
I use something along these lines to ensure I don't have multiple tweens fighting over the same object. The implementation of mapping objects to a tween in the same, but I also have an This prevents things jittering and breaking when you, for example, have a tween pan the camera from one scene to another, but the user presses a button to tween back to the first scene before the first tween has finished. Could this perhaps be worked into flixel, too? |
@JoeCreates How do you remove the key-val of the tween ends normally? Do you search through all the pairs looking or is it manual? I had something automatic like that, but it didn't seem very performant. |
@MSGhero I didn't automate the removal. For the most past I just left the tweens in the map even after they were finished, seeing as it's fine to cancel an already finished tween. I haven't had any need to remove them, yet, seeing as I have mainly used this for UI with a finite number of elements, and so the map is generally small. It's useful to be able to manually remove them, of course. I just haven't needed to remove them at all , yet. |
I was thinking in terms of garbage collection. You have the tween and the object it references chilling in the map. |
@MSGhero It's not something I've needed to consider yet, due to how frequently I reuse those objects. |
I don't like this pull anymore. I'll leave #1458 up so it gets remembered, but I don't think anyone wants to have to bind a function and waste an onComplete to use it. A proper way to do this should be a lazily created "tween manager" inside of each FlxObject and maybe an optional |
#1458
I chose to make it manual adding and removing/canceling tweens instead of automatic so performance wouldn't be affected.
Usage would be like