If you’re looking to code something for mobile touch-based controls that acts like a turn table (or old iPod control ring), here’s something I threw together. Originally I thought it’d be enough to just rotate to where the user was touching, but that doesn’t accomplish that drag-rotation effect.
CREATE
held = false; //whether or not they’re touching the ring
curangle = 0; //current angle from center of ring to touch location
lastangle = 0; //last angle
deltaangle = 0; //change in angle
ringangle = 0; //angle the ring should be facing now
Left Button Press
held = true;
curangle = pointdirection(x,y,mousex,mousey);
lastangle = curangle;
Left Released
held = false;
Mouse Leave
held = false;
Step
if(held)
{
curangle = pointdirection(x,y,mousex,mousey);
angledelta = lastangle-curangle;
lastangle = curangle;
ringangle-=angle_delta;
}