onComplete - can I pass variables / arguments to the function?

I want to do something like this, onComplete=activateButtons("game"), for a transition but it doesnt work.

Is there a correct way of doing the above?

Can you elab a bit more?

Carlos

ok here goes

this works
transition.to(masterGroup, { rotation=90, time=400, delta=true, onComplete=backgroundOrientationReset } )

and calls the function backgrountOrientationReset() when the transition has completed

problem is that the function requires a variable to be passed like backgrountOrientationReset($foo), so the question is how do I pass $foo to the function call of the onComplete part of a transition?

One possibility is using a table:

local backgroundOrientationReset = { someParam = "default value" }

backgroundOrientationReset.onComplete = function( self ) print( self.someParam ) end

backgroundOrientationReset.someParam = "hello world"

transition.to(masterGroup, { rotation=90, time=400, delta=true, onComplete=backgroundOrientationReset } )

Good question, and possible addition for the API?

I'm realizing that I need to get much more comfortable with Lua tables, but as an AS/Tweenlite fan, It would be great if Corona had an optional "onCompleteParams = [ ]" syntax to send a comma separated list of property and values into the function.

transition.to(masterGroup, { rotation=90, time=400, delta=true, onComplete=backgroundOrientationReset, onCompleteParams=[aParam:$foo, bParam:$morefoo} )

Great suggestion. Adding it to our feature list.

Is there any news on this - the last post was in 2009. I saw nothing in the documentation.

Ultimately I need to loop an animation. Right now, I'm basically having a function be called with the transitions to loop & the iteration number & max iteration. Sadly this isn't working. I can't hard-code it as I'm doing a load from a JSON file. Any suggestions?

I tried the table mention above and it didn't work. I'm new to LUA...

views:1710 update:2012/1/13 9:04:04
corona forums © 2003-2011