Timer.lua 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. require "Polycode/EventDispatcher"
  2. class "Timer" (EventDispatcher)
  3. EVENT_TRIGGER = 0
  4. function Timer:Timer(...)
  5. for k,v in pairs(arg) do
  6. if type(v) == "table" then
  7. if v.__ptr ~= nil then
  8. arg[k] = v.__ptr
  9. end
  10. end
  11. end
  12. if self.__ptr == nil and arg[1] ~= "__skip_ptr__" then
  13. self.__ptr = Polycore.Timer(unpack(arg))
  14. Polycore.__ptr_lookup[self.__ptr] = self
  15. end
  16. end
  17. function Timer:Pause(paused)
  18. local retVal = Polycore.Timer_Pause(self.__ptr, paused)
  19. end
  20. function Timer:isPaused()
  21. local retVal = Polycore.Timer_isPaused(self.__ptr)
  22. return retVal
  23. end
  24. function Timer:getTicks()
  25. local retVal = Polycore.Timer_getTicks(self.__ptr)
  26. return retVal
  27. end
  28. function Timer:Update(ticks)
  29. local retVal = Polycore.Timer_Update(self.__ptr, ticks)
  30. end
  31. function Timer:Reset()
  32. local retVal = Polycore.Timer_Reset(self.__ptr)
  33. end
  34. function Timer:hasElapsed()
  35. local retVal = Polycore.Timer_hasElapsed(self.__ptr)
  36. return retVal
  37. end
  38. function Timer:getElapsedf()
  39. local retVal = Polycore.Timer_getElapsedf(self.__ptr)
  40. return retVal
  41. end