Here’s the situation. I want a square object to continuously move in y-direction as long as I’m touching the screen. Based on the code, I have it should give me a continuous movement of the square object, but, only when I’m sliding with my finger on the touch screen, the object moves. I want the square object to continuously move when I’m touching the screen on the same spot.
I tried using both timer and runtime event listener to no avail. What’s the fix here?
local squareTimer
local function squareMoveUp()
square.y = square.y - 5
end
local holding = ‘false’
local function startMove(event)
if event.phase == ‘began’ then
--Runtime:addEventListener(‘enterFrame’,squareMoveUp)
squareTimer = timer.performWithDelay(200,squareMoveUp,0)
elseif event.phase == ‘ended’ then
--Runtime:removeEventListener(‘enterFrame’,squareMoveUp)
end
return true
end
background:addEventListener(‘touch’,squareMoveUp)