I’m having really hard time trying to come up with the best way to do this. What I want is:
1- move an object using X value
2- change its color
3- wait for few seconds
4- move it back
5- repeat
That object has its own module:
local P = {} function P.new( group, img, x, y, width, height ) local player = display.newImageRect( group, img, width, height ) player.x = x or 0 player.y = y or 0 function player:moveRight( time,x, backX ) transition.to( self, {time=time, x=self.x + x, onComplete=function() player:moveBack(500, backX) end} ) end function player:moveBack( time,x ) transition.to(self, {time=time, x=x}) end return player end return P
The above is a very basic behavior without repeating. I tried many different variations and used timers and passed a lot of arguments around, but things always get complex and managing them later becomes a pain, like if I want to cancel that behavior entirely.
How do you guys usually go about doing stuff like this?
