Hello guys, I’m new to this and I wanted to make the object rotate following the mouse cursor, but the object rotated only to one side, I wanted the object to rotate quickly in any direction, following the mouse. Can someone help me?
–code
local triangle = display.newPolygon( display.contentCenterX, display.contentCenterY, { 0, 0, -5, 35, 5, 35 } )
local function Mouse( event )
--tempX = dot.x + Cos(Rad(angle)) * radius
--tempY = dot.y + Sin(Rad(angle)) * radius
triangle.rotation = triangle.rotation+2;
--angle = angle+1
end
local function moveForward()
event.x = triangle.x + Cos(math.rad(triangle.rotation))*1
event.y = triangle.y + Sin(math.rad(triangle.rotation))*1
end
Runtime:addEventListener( ‘mouse’, Mouse)