Transition.to 'onComplete' function is not working..

I have the following line of code:

transition.to(addScore, {time = 1000, alpha = 0, onComplete = deleteFade(addScore)})

However, every time it fires, ‘deleteFade(addScore)’ is called exactly when the transition is started. From my understanding, shouldn’t the ‘onComplete’ listener fire off once the transition has completed?

I basically want to create an object, transition its alpha level to 0, and then remove the object. But the above code is removing the object before its alpha has been reduced.

You’re setting that up incorrectly.  Use a closure.

transition.to(addScore, {time = 1000, alpha = 0, onComplete = function() deleteFade(addScore) end })

To explain why:

When you specify a function with () and parameters you are saying:  execute this function and assign the returned value to the onComplete handler. Most likely your function isn’t returning a function.

When you specify a function without the () or any parameters you’re saying:  assign the address of the function to the onComplete handler and when the transition completes, the function will be called. However you cannot pass parameters this way.

The option in the post above, uses an anonymous function (or also called a closure) to assign an anonymous function (function does not have a name) to your onComplete and the code inside that function calls your function with a parameter.

Rob

You’re setting that up incorrectly.  Use a closure.

transition.to(addScore, {time = 1000, alpha = 0, onComplete = function() deleteFade(addScore) end })

To explain why:

When you specify a function with () and parameters you are saying:  execute this function and assign the returned value to the onComplete handler. Most likely your function isn’t returning a function.

When you specify a function without the () or any parameters you’re saying:  assign the address of the function to the onComplete handler and when the transition completes, the function will be called. However you cannot pass parameters this way.

The option in the post above, uses an anonymous function (or also called a closure) to assign an anonymous function (function does not have a name) to your onComplete and the code inside that function calls your function with a parameter.

Rob