Hi I need to use a static object in my game and I need to make a left and right continues movement with two button. But my object only move once. Help
here is the code of the left button:
local function leftBtnTouch( event ) local function moveLeft() box.x = boxX- 10 --where boxX is the inicial position of the box in scene:create() end if event.phase == "began" then print( "left button touch" ) moveBoxToLeft = timer.performWithDelay(100, moveLeft(), -1) elseif event.phase == "ended" then if moveBoxToLeft ~= nil then timer.cancel( moveBoxToLeft ) moveBoxToLeft = nil end end return true end
I set -1 timer interactions to repeat till "ended" phase come but the box only move once. To give a better example, I am trying to make a game where there is a box below that picks up the objects that fall from above and I need to move it from left to right to catch the objects. The box needs to be static, is the only way I can do my idea using the physics engine. I would not like the player to make multiple taps to move the box, rather I look for a continuous movement that stops at the "ended" phase.
Thanks in advance DoDi