How to transfer parameters to the function in onComplete event (Lua + Corona SDK)
transition.to(obj, {time = 1000, x = toEnemy.x, y = toEnemy.y, onComplete = onHit} )
----
transition.to( target, params )
----
params is:
params.time
params.transition
params.delay
params.delta
params.onStart
params.onComplete
there isn’t “params.onCompleteParams”, but I want to transfer parameters to my
function without using global variables
Lua functions are actually closures. This means that they capture the values of local variables outside the function that are in their scope.
By using an anonymous function as the
onCompletehandler, you can do the following: