I’ve been racking my brain for two days trying to figure out a solution to a problem most people probably try to actively avoid!
I have a sort of “ticker” that moves back and forth on just the y axis. As of now, the dragging animation is smooth as silk but that’s exactly what I don’t want. I need it to move incrementally at 12px a time either way. Here’s what I have so far:
function tBand:touch( event ) if event.phase == "began" then print( "Touch event began on: " .. self.id .. " at X:" .. event.x .. " and Y:" .. event.y) -- set touch focus self.isFocus = true self.markX = self.x -- store x location of object elseif self.isFocus then if event.phase == "moved" then print( "Moved phase of touch event detected." ) local x = (event.x - event.xStart) + self.markX local speed = -12 self.x = x+speed --audio.play( audClick ) elseif event.phase == "ended" or event.phase == "cancelled" then print(self.id .. " x:" .. event.x) print(self.id .. " x:" .. self.x) local function resetFocus( ) -- reset touch focus display.getCurrentStage():setFocus( nil ) self.isFocus = nil end end end return true end tBand:addEventListener( "touch", tBand )
On line 104 and 105 I attempted to add the variable “speed” in order to achieve what I want. If I barely move the ticker (tBand), you can see it jump 12px like I want it to but it only does it once and then continues to drag smoothly.
I’m thinking I need to have some kind of enterFrame eventListener but my mind’s drawing a blank on how to implement it… Any help at all would be greatly appreciated!
Robbie