Hi andreib,
try this code, I changed the rectangle to text, so that you can see the rotation better
--Rotate a rectangle based on sliding the finger on the screen
--Variables used locally
local rect
local startX, startY
local dX, dY
local amountToRotate
--Functions
onTouch = function(event)
if event.phase=="began" then
startX = event.x
startY = event.y
elseif event.phase=="ended" then
--
elseif event.phase =="moved" then
dX = startX - event.x
dY = startY - event.y
rect.rotation = (dY \* amountToRotate)
end
end
amountToRotate = (360/display.contentHeight)
--rect = display.newRect(display.contentWidth/2,display.contentHeight/2,100,100)
--rect:setFillColor(255,0,0,200)
rect = display.newText("Hello", display.contentWidth/2, display.contentHeight/2)
rect:setTextColor(255,255,255)
Runtime:addEventListener("touch", onTouch)
This could be optimised for better handling, but to get an idea of what you want, I think this is a good start for you.
cheers,
Jayant C Varma [import]uid: 3826 topic_id: 3096 reply_id: 9235[/import]