Timer.js 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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.prototype = Object.create(EventDispatcher.prototype);
  8. Duktape.fin(Timer.prototype, function (x) {
  9. if (x === Timer.prototype) {
  10. return;
  11. }
  12. Polycode.Timer__delete(x.__ptr)
  13. })
  14. Timer.prototype.Pause = function(paused) {
  15. Polycode.Timer_Pause(this.__ptr, paused)
  16. }
  17. Timer.prototype.isPaused = function() {
  18. return Polycode.Timer_isPaused(this.__ptr)
  19. }
  20. Timer.prototype.getTicks = function() {
  21. return Polycode.Timer_getTicks(this.__ptr)
  22. }
  23. Timer.prototype.Update = function(ticks) {
  24. Polycode.Timer_Update(this.__ptr, ticks)
  25. }
  26. Timer.prototype.Reset = function() {
  27. Polycode.Timer_Reset(this.__ptr)
  28. }
  29. Timer.prototype.hasElapsed = function() {
  30. return Polycode.Timer_hasElapsed(this.__ptr)
  31. }
  32. Timer.prototype.getElapsedf = function() {
  33. return Polycode.Timer_getElapsedf(this.__ptr)
  34. }
  35. Timer.prototype.setTimerInterval = function(msecs) {
  36. Polycode.Timer_setTimerInterval(this.__ptr, msecs)
  37. }