I use transition.to from some object
I want to check that object is move
How to method from check or detect object moving?
thank you
I use transition.to from some object
I want to check that object is move
How to method from check or detect object moving?
thank you
There are several ways to approach this. Perhaps the best one is to put an Runtime “enterFrame” listener on the object that gets called very frame update (30 or 60 times a second). And you can put in whatever tests you need to and reactions to positions.
local box = display.newRect( 100, 100, 50, 50 ) function box:enterFrame() if self.x \> display.contentWidth then -- box is off screen print("off screen") Runtime:removeEventListener( "enterFrame", self ) end end Runtime:addEventListener( "enterFrame", box ) transition.to( box, { time=1000, x = display.contentWidth + 100 } )
See: https://coronalabs.com/blog/2015/08/25/tutorial-animation-with-enterframe-listeners/
Thank you
I will try it.
There are several ways to approach this. Perhaps the best one is to put an Runtime “enterFrame” listener on the object that gets called very frame update (30 or 60 times a second). And you can put in whatever tests you need to and reactions to positions.
local box = display.newRect( 100, 100, 50, 50 ) function box:enterFrame() if self.x \> display.contentWidth then -- box is off screen print("off screen") Runtime:removeEventListener( "enterFrame", self ) end end Runtime:addEventListener( "enterFrame", box ) transition.to( box, { time=1000, x = display.contentWidth + 100 } )
See: https://coronalabs.com/blog/2015/08/25/tutorial-animation-with-enterframe-listeners/
Thank you
I will try it.