Advertisement
alestane

Rotating wheel

Jun 25th, 2014
346
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local wheel = display.newGroup()
  2. wheel.x, wheel.y = display.contentCenterX, display.contentCenterY
  3.  
  4. display.newRect(wheel, 50, 0, 10, 10)
  5.  
  6. display.newCircle(wheel, 0, 0, 5)
  7.  
  8. function wheel:touch(event)
  9.     local x, y = self:contentToLocal(event.x, event.y)
  10.     if event.phase == 'moved' then
  11.         self.rotation = self.rotation + math.deg(math.atan2(y, x))
  12.         for i= 1, self.numChildren do
  13.             self[i].rotation = -self.rotation
  14.         end
  15.     end
  16. end
  17.  
  18. Runtime:addEventListener('touch', wheel)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement