touch event and loop an action

i have a touch event:
Runtime:removeEventListener( “touch”, touch )

and i apply a linearImpluse …is woking great but i want the code keep aplying that impluse is the event touch is still active. I means…if i am still touching the screen, apply more impulses…

Any idea? [import]uid: 113117 topic_id: 26470 reply_id: 326470[/import]

Well,

a) If you apply the impulse during event.phase == “moved” then it will apply rapidly, but only when there is some finger movement.

b) You could also set off a timer during event.phase == “began” that triggers the impulse periodically, and then cancel that timer during event.phase == “ended” or event.phase == “cancelled”. [import]uid: 41884 topic_id: 26470 reply_id: 107385[/import]

Thanks, the second looks like the right choice.
Regards bro. [import]uid: 113117 topic_id: 26470 reply_id: 107396[/import]

Timer.cancel gives me an error, why?

local function touch( event )

if event.phase == “began” then

local move=timer.performWithDelay(1, moveup, -1)

elseif event.phase == “moved” then

elseif event.phase == “ended” or event.phase == “cancelled” then

timer.cancel( move )
end

return true – IMPORTANT

end [import]uid: 113117 topic_id: 26470 reply_id: 107399[/import]

Neither:

local function touch( event )

local move

if event.phase == “began” then

– Touch has began
move=timer.performWithDelay(1, moveup, -1)

elseif event.phase == “moved” then

– User has moved their finger, while touching

elseif event.phase == “ended” or event.phase == “cancelled” then

– Touch has ended; user has lifted their finger
timer.cancel( move )
end

return true – IMPORTANT

end
Terminal:
Runtime error
?:0: attempt to index a nil value
stack traceback:
[C]: ?
?: in function ‘cancel’
[import]uid: 113117 topic_id: 26470 reply_id: 107400[/import]

Como juan palomo, yo me lo guiso yo me lo como.
SOLUTION:

ship.move=timer.performWithDelay(1, moveup, -1)

timer.cancel( ship.move ) [import]uid: 113117 topic_id: 26470 reply_id: 107402[/import]