If/else confusing....

If all you want to do is use a transition to move an object from one corner to another and back again, in an infinite loop, I really don’t know why you even need IF statements. I mean, it’s not like you don’t know when the object reaches 0,0… so you don’t need to check for that. You know it reaches 0,0 when the transition finishes…

-- transition help local circle = display.newCircle( 0,0,50 ) local trans local toBR, toTL toBR = function( obj, time ) trans = transition.to( obj, { time=time, x=display.contentWidth, y=display.contentHeight, onComplete=function() toTL( obj, time ) end } ) end toTL = function( obj, time ) trans = transition.to( obj, { time=time, x=0, y=0, onComplete=function() toBR( obj, time ) end } ) end toBR( circle, 2000 ) -- when you want to stop the infinite transitions, simply call this: -- transition.cancel( trans ) -- trans = nil -- but make sure you nil it afterwards

I thought I HAD to use an if statement… I’m still an amatuer. Among all the things in life that I can do well, programming has always been my “personal cryptonite”. I’m hoping to end that by learning corona sdk! Thanks for the post. I’m not understanding all of what the above does, but I’m gonna go play around in glider with it, right now. Thanks JonPM too, I’m gonna play with your posted sample code too. :slight_smile:

What in the code above do you not get? I can comment it, but it’ll mean more if you tell me what is confusing.