Timer.lua 1014 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. end
  15. end
  16. function Timer:Pause(paused)
  17. local retVal = Polycore.Timer_Pause(self.__ptr, paused)
  18. end
  19. function Timer:isPaused()
  20. local retVal = Polycore.Timer_isPaused(self.__ptr)
  21. return retVal
  22. end
  23. function Timer:getTicks()
  24. local retVal = Polycore.Timer_getTicks(self.__ptr)
  25. return retVal
  26. end
  27. function Timer:Update(ticks)
  28. local retVal = Polycore.Timer_Update(self.__ptr, ticks)
  29. end
  30. function Timer:Reset()
  31. local retVal = Polycore.Timer_Reset(self.__ptr)
  32. end
  33. function Timer:hasElapsed()
  34. local retVal = Polycore.Timer_hasElapsed(self.__ptr)
  35. return retVal
  36. end
  37. function Timer:getElapsedf()
  38. local retVal = Polycore.Timer_getElapsedf(self.__ptr)
  39. return retVal
  40. end