I’ve tried multiple methods of trying to get things to move constantly when the screen is touched and held. Nothing is working for me. Can someone please help?
I’ve tried this and variations and it still has not worked:
local holding = false local function enterFrameListener() if holding then -- Holding button -- Code here -- Code here -- Code here else -- Not holding -- Code here -- Code here -- Code here end end local function touchHandler( event ) if event.phase == "began" then display.getCurrentStage():setFocus( event.target ) event.target.isFocus = true Runtime:addEventListener( "enterFrame", enterFrameListener ) holding = true elseif event.target.isFocus then if event.phase == "moved" then elseif event.phase == "ended" then holding = false Runtime:removeEventListener( "enterFrame", enterFrameListener ) display.getCurrentStage():setFocus( nil ) event.target.isFocus = false end end return true end
Thanks, but I don’t think that’s what I need. I’m trying to make a game in which if you touch the left side of the screen you fly to the left, and if you touch the right side of the screen, you fly to the right (like the controls of Super Hexagon). The main character is stationary in the middle, and the background, stars, and other objects move.
I understand that, but I’m not sure I’d know how to implement that, when the character is moving through infinite space constantly. Off-topic, but that doesn’t really help me with a touch and hold function.
Thanks, but I don’t think that’s what I need. I’m trying to make a game in which if you touch the left side of the screen you fly to the left, and if you touch the right side of the screen, you fly to the right (like the controls of Super Hexagon). The main character is stationary in the middle, and the background, stars, and other objects move.
I understand that, but I’m not sure I’d know how to implement that, when the character is moving through infinite space constantly. Off-topic, but that doesn’t really help me with a touch and hold function.