Advertisement
Guest User

weird RAF

a guest
Aug 13th, 2013
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Game.prototype.stopLoop = function () {
  2.     if (this.running) {
  3.  
  4.         console.log('cancel the game now');
  5.         window.webkitCancelRequestAnimationFrame(this.animationID);
  6.         this.running = false;
  7.        
  8.     }
  9. };
  10.  
  11. Game.prototype.startLoop = function (arg) {
  12.  
  13.     console.log('starting');
  14.  
  15.     var parent = this;
  16.  
  17.     this.running = true;
  18.  
  19.  
  20.  
  21.     (function tick() {
  22.  
  23.         parent.update();
  24.  
  25.         if (parent.running) parent.animationID = webkitRequestAnimationFrame(tick);
  26.            
  27.     }());
  28.  
  29. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement