EventHandling.lua 530 B

12345678910111213141516171819202122
  1. class "ImageRotator" (EventHandler)
  2. timer = Timer(true, 1000)
  3. function ImageRotator:ImageRotator(image)
  4. self.image = image
  5. self:EventHandler()
  6. end
  7. function ImageRotator:handleEvent(e)
  8. if e:getDispatcher() == timer and e:getEventCode() == EVENT_TRIGGER then
  9. self.image:setRotation(self.image:getRotation()+90)
  10. end
  11. end
  12. screen = Screen()
  13. image = ScreenImage("polycode_logo.png")
  14. screen:addChild(image)
  15. rotator = ImageRotator(image)
  16. timer:addEventListener(rotator, EVENT_TRIGGER)