TouchListener problem...

I have a little problem…

Here is my touchListener, if I touch left/right half my object should rotate continuously if I hold but stop if I let go. As of now, it starts to rotate and doesn’t stop when touch phase “ended”. If I touch again it increase the speed…

I just want it to rotate only as long as I hold on either side of the screen, am I missing out on some basics here or what?!?

&nbsp; local centerX = display.contentWidth/2 local centerY = display.contentHeight/2 &nbsp; local runtime = 0 &nbsp; local function getDeltaTime() &nbsp; &nbsp;local temp = system.getTimer() &nbsp;--Get current game time in ms &nbsp; &nbsp;local dt = (temp-runtime) / (1000/60) &nbsp;--60fps or 30fps as base &nbsp; &nbsp;runtime = temp &nbsp;--Store game time &nbsp; &nbsp;return dt end &nbsp; local dt = getDeltaTime() &nbsp; local group = display.newGroup() &nbsp; local bg = display.newRect(0, 0, \_W, \_H) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;bg:setFillColor(0, 0, 0,255) &nbsp; &nbsp; &nbsp;&nbsp; local rect = display.newRect(group, centerX, centerY, 50, 50) &nbsp; &nbsp; &nbsp; &nbsp; rect:setFillColor(220, 20, 220, 255) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; group:setReferencePoint(display.CenterReferencePoint) &nbsp; local function touchListener(event) &nbsp;&nbsp;&nbsp;&nbsp;local phase = event.phase &nbsp;&nbsp;&nbsp;&nbsp;local target = event.target &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;local function update() &nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if event.x \> centerX then &nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;group.rotation = group.rotation + (1\*dt) &nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;elseif event.x \< centerX then &nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;group.rotation = group.rotation - (1\*dt) &nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; end &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; if phase == "began" then &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;Runtime:addEventListener("enterFrame", update) &nbsp; &nbsp; elseif phase == "moved" then &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; elseif phase == "ended" or phase == "cancelled" then &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Runtime:removeEventListener("enterFrame", update) &nbsp; &nbsp; &nbsp; end &nbsp; &nbsp; return true end &nbsp; bg:addEventListener("touch",touchListener)

Cancelled phase is usually called by system so generally you won’t produce it youself. Ended phase is called only if you release finger but it was previously on object. So if you touch object, drag finger out of object and release finger then ‘ended’ will never be called.

Cancelled phase is usually called by system so generally you won’t produce it youself. Ended phase is called only if you release finger but it was previously on object. So if you touch object, drag finger out of object and release finger then ‘ended’ will never be called.