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

Tween callback params #14

Closed
alryazanov opened this issue May 11, 2015 · 6 comments
Closed

Tween callback params #14

alryazanov opened this issue May 11, 2015 · 6 comments
Assignees
Labels

Comments

@alryazanov
Copy link

Hi!

I saw in the documentation that the transfer parameters in the callback goes through lambda/closures.
But why not add a transfer custom parameters (eg params[])? Sometimes closures are not desirable. In addition, it would be helpful to have in the callback information about Tween who raised him.

Thanks!

@Demigiant
Copy link
Owner

Hi!

I preferred to avoid params and/or specific parameter in order to have a cleaner and more usable method signature for callbacks. You can still pass the tween itself via lambda/closures, as long as you assign the callback after assigning the tween.

Cheers!

@Demigiant Demigiant self-assigned this May 11, 2015
@alryazanov
Copy link
Author

I'm just worried about the overhead of closures, for example if you add callbacks with element closure in the loop for move a array of elements.

@Demigiant
Copy link
Owner

I totally understand your worries, but it's better to have closures than to have to worry about having tweens that are too heavy, since every callback adds around 4B to the tween itself, even if unused. So closures seem to me like the best necessary evil. I'll ponder about this more though: let me know if you have more thoughts.

@wyyayy
Copy link

wyyayy commented Jun 12, 2016

Closures doesn't work if use OnComplete in a for loop.

@optimisez
Copy link

Hi @Demigiant, is there any solution to make it gc free without using lambda/closures or params[]?

@Demigiant
Copy link
Owner

Ahoy!
If you pass a direct reference to a method without generating an anonymous one via a lambda, GC is avoided there.
myTween.OnComplete(SomeOtherMethod)

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

No branches or pull requests

4 participants