I have a rotate/drag platform function that is working (it’s pretty confusing). It works like, the first tap drags the platform across the screen and then the second tap rotates it, then third tap drags it etc… I would like to make it that one tap and hold drags the platform and a double tap and hold rotates it, but I can’t seem to figure this out.
Here’s the code
--------------------------------------------------------------------------- Rotate platform local function movePlatform(event) platformTouched = event.target if (event.phase == "began") then display.getCurrentStage():setFocus( platformTouched ) if platformTouched.touchMode == "move" then -- here the first position is stored in x and y platformTouched.startMoveX = platformTouched.x platformTouched.startMoveY = platformTouched.y platformTouched.x1 = event.x platformTouched.y1 = event.y elseif platformTouched.touchMode == "rotate" then end elseif (event.phase == "moved") then if platformTouched.touchMode == "move" then -- here the distance is calculated between the start of the movement and its current position of the drag platformTouched.x = (event.x - event.xStart) + platformTouched.startMoveX platformTouched.y = (event.y - event.yStart) + platformTouched.startMoveY elseif platformTouched.touchMode == "rotate" then platformTouched.x2 = event.x platformTouched.y2 = event.y angle1 = 180/math.pi \* math.atan2(platformTouched.y1 - platformTouched.y , platformTouched.x1 - platformTouched.x) angle2= 180/math.pi \* math.atan2(platformTouched.y2 - platformTouched.y , platformTouched.x2 - platformTouched.x) differencebetweenangles = angle1 - angle2 --rotate it platformTouched.rotation = platformTouched.rotation - differencebetweenangles platformTouched.x1 = platformTouched.x2 platformTouched.y1 = platformTouched.y2 end elseif event.phase == "ended" or event.phase == "cancelled" then --each time we release the platform, toggle between move and rotate mode if platformTouched.touchMode == "move" then platformTouched.touchMode = "rotate" else platformTouched.touchMode = "move" end display.getCurrentStage():setFocus( nil ) end return true end platform:addEventListener("touch", movePlatform)