Hello, I have a object
MyObject = display.newImageRect( "MyObject .png", 50, 50 )
MyObject .x = centerX
MyObject .y = centerY
that moves with accelerometer event:
local function onAccelerate( event )
MyObject .x = centerX + (centerX \* event.xGravity)
MyObject .y = centerY + (centerY \* event.yGravity \* -1)
--- rotation angle????
local angle = ( math.atan2( MyObject .y - centerY , MyObject - centerX ) \* ( 180 / pi ) ) + 90
MyObject .rotation = angle
end
where
local centerX = display.contentWidth / 2
local centerY = display.contentHeight / 2
My question is how to set rotation angle properly so picture MyObject.png could follow movement of the object?
[import]uid: 65687 topic_id: 28409 reply_id: 328409[/import]
[import]uid: 52491 topic_id: 28409 reply_id: 114745[/import]