component.lua 499 B

123456789101112131415161718192021222324252627
  1. Component = class()
  2. function Component:draw()
  3. self.gooey:draw(self)
  4. end
  5. function Component:on(event, callback)
  6. self.event = self.event or Event()
  7. self.event:on(event, callback)
  8. end
  9. function Component:emit(event, data)
  10. if not self.event then return end
  11. self.event:emit(event, data)
  12. end
  13. function Component:focused()
  14. return self.gooey.focused == self
  15. end
  16. function Component:getOffset(x, y)
  17. return 0, 0
  18. end
  19. function Component:getMousePosition()
  20. return love.mouse.getPosition()
  21. end