Rotation

I want to make an object rotate non-stop. Any ideas? [import]uid: 104376 topic_id: 22072 reply_id: 322072[/import]

It’s not that hard.

  
local rotatingObject = display.newImage("rotateme.png")  
local rotatingObject.x = display.contentWidth / 2  
local rotatingObject.y = display.contentHeight / 2  
local rotateSpeed = 2 -- in seconds  
local function rotateMe(event)  
 rotatingObject.rotation = rotatingObject.rotation + (12 / rotateSpeed)  
 return true  
end  
  
Runtime:addEventListener("enterFrame", rotateMe)  
  

The math here is there are 360 degrees to rotate through. At 30 frames per second for your object to rotate a full turn in 1 second means it needs to move 12 degrees per frame (360 / 12). If you’re doing a 60fps game, that becomes 6 degrees per frame. Want that to last over 2 seconds? Set rotateSpeed to 2. Avoid a rotateSpeed of 0.

[import]uid: 19626 topic_id: 22072 reply_id: 87705[/import]

Perfect! just what I needed! Thanks! [import]uid: 104376 topic_id: 22072 reply_id: 87747[/import]