I have a menu page where I can click and slide to the next page. How can I make it so that I can hold and slide the page back and forth to make it more smooth?(Something like the homepage in Apple devices)
Currently what I have is that it moves to the next page once its being slide its like one movement at one time. Possible to make it so that once I hold down and I can slide back and forth?
Here’s the code to make it slide:
function onTouch(event) if event.phase == "began" then xStart = event.x elseif event.phase == "moved" then -- elseif event.phase == "ended" then -- previous page if xStart \< event.x and event.x - xStart \>= 100 then if currentPage \>= 2 then -- min + 1 --transition.to(groupStars,{x=groupStars.x + screenWidth,time = 300}) transition.to(groupBg, {x = groupBg.x + screenWidth , time=300}) dot\_yellow.x = dot\_yellow.x - 21 currentPage = currentPage - 1 end -- next page elseif xStart \> event.x and xStart - event.x \>= 100 then if currentPage \<= maxPage-1 then -- max - 1 --transition.to(groupStars,{x=groupStars.x - screenWidth, time = 300}) transition.to(groupBg, {x = groupBg.x - screenWidth, time=300}) dot\_yellow.x = dot\_yellow.x + 21 --dots.x = dots.x - screenWidth--math.floor(screenWidth/2) currentPage = currentPage + 1 end end end end Runtime:addEventListener("touch", onTouch)