Timer.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. require('Polycode/EventDispatcher')
  2. function Timer(triggerMode,msecs) {
  3. if(arguments[0] != "__skip_ptr__") {
  4. this.__ptr = Polycode.Timer(triggerMode,msecs)
  5. }
  6. }
  7. Timer.EVENT_TRIGGER = 0
  8. Timer.prototype = Object.create(EventDispatcher.prototype)
  9. Duktape.fin(Timer.prototype, function (x) {
  10. if (x === Timer.prototype) {
  11. return;
  12. }
  13. Polycode.Timer__delete(x.__ptr)
  14. })
  15. Timer.prototype.Pause = function(paused) {
  16. Polycode.Timer_Pause(this.__ptr, paused)
  17. }
  18. Timer.prototype.isPaused = function() {
  19. return Polycode.Timer_isPaused(this.__ptr)
  20. }
  21. Timer.prototype.getTicks = function() {
  22. return Polycode.Timer_getTicks(this.__ptr)
  23. }
  24. Timer.prototype.Update = function(ticks) {
  25. Polycode.Timer_Update(this.__ptr, ticks)
  26. }
  27. Timer.prototype.Reset = function() {
  28. Polycode.Timer_Reset(this.__ptr)
  29. }
  30. Timer.prototype.hasElapsed = function() {
  31. return Polycode.Timer_hasElapsed(this.__ptr)
  32. }
  33. Timer.prototype.getElapsedf = function() {
  34. return Polycode.Timer_getElapsedf(this.__ptr)
  35. }
  36. Timer.prototype.setTimerInterval = function(msecs) {
  37. Polycode.Timer_setTimerInterval(this.__ptr, msecs)
  38. }