Use requestAnimationFrame (naively) instead of setInterval.
Cat's Eye Technologies
11 years ago
66 | 66 |
};
|
67 | 67 |
|
68 | 68 |
Cyclobots = function() {
|
69 | |
var interval_id = undefined;
|
|
69 |
var request = undefined;
|
70 | 70 |
var ctx = undefined;
|
71 | 71 |
var canvas = undefined;
|
72 | 72 |
var selected = undefined;
|
|
152 | 152 |
e.preventDefault();
|
153 | 153 |
});
|
154 | 154 |
|
155 | |
interval_id = setInterval(this.draw, 25);
|
|
155 |
var $this = this;
|
|
156 |
var animFrame = function(time) {
|
|
157 |
$this.draw();
|
|
158 |
request = requestAnimationFrame(animFrame);
|
|
159 |
};
|
|
160 |
request = requestAnimationFrame(animFrame);
|
156 | 161 |
};
|
157 | 162 |
|
158 | 163 |
this.selectABot = function(can_x, can_y) {
|
46 | 46 |
};
|
47 | 47 |
|
48 | 48 |
Fingerspelling = function() {
|
49 | |
var intervalId;
|
|
49 |
var request;
|
50 | 50 |
var options;
|
51 | 51 |
|
52 | 52 |
var canvas;
|
|
153 | 153 |
e.preventDefault();
|
154 | 154 |
});
|
155 | 155 |
|
156 | |
var self = this;
|
157 | |
intervalId = setInterval(self.draw, 20);
|
|
156 |
var $this = this;
|
|
157 |
var animFrame = function(time) {
|
|
158 |
$this.draw();
|
|
159 |
request = requestAnimationFrame(animFrame);
|
|
160 |
};
|
|
161 |
request = requestAnimationFrame(animFrame);
|
158 | 162 |
};
|
159 | 163 |
};
|
84 | 84 |
|
85 | 85 |
HeronsisHermnonicii = function() {
|
86 | 86 |
var ctx;
|
87 | |
var intervalId;
|
|
87 |
var request;
|
88 | 88 |
|
89 | 89 |
var manager;
|
90 | 90 |
var landscape = [];
|
|
126 | 126 |
this.init = function(c) {
|
127 | 127 |
canvas = c;
|
128 | 128 |
ctx = canvas.getContext('2d');
|
129 | |
var self = this;
|
130 | 129 |
|
131 | 130 |
manager = new yoob.SpriteManager();
|
132 | 131 |
manager.init(canvas);
|
|
151 | 150 |
treescape[i] = canvas.height * 0.75 + (Math.random() * 60 - 30);
|
152 | 151 |
}
|
153 | 152 |
|
154 | |
intervalId = setInterval(function() { self.draw(); }, 33);
|
|
153 |
var $this = this;
|
|
154 |
var animFrame = function(time) {
|
|
155 |
$this.draw();
|
|
156 |
request = requestAnimationFrame(animFrame);
|
|
157 |
};
|
|
158 |
request = requestAnimationFrame(animFrame);
|
155 | 159 |
};
|
156 | 160 |
}
|
0 | 0 |
HirsuteMiasma = function() {
|
1 | 1 |
var canvas;
|
2 | 2 |
var ctx;
|
3 | |
var intervalId;
|
|
3 |
var request;
|
4 | 4 |
|
5 | 5 |
var x;
|
6 | 6 |
var y;
|
|
74 | 74 |
canvas = c;
|
75 | 75 |
ctx = canvas.getContext('2d');
|
76 | 76 |
this.draw();
|
77 | |
intervalId = setInterval(this.draw, 50);
|
|
77 |
var $this = this;
|
|
78 |
var animFrame = function(time) {
|
|
79 |
$this.draw();
|
|
80 |
request = requestAnimationFrame(animFrame);
|
|
81 |
};
|
|
82 |
request = requestAnimationFrame(animFrame);
|
78 | 83 |
}
|
79 | 84 |
}
|
77 | 77 |
var overlayCanvas;
|
78 | 78 |
var ctx;
|
79 | 79 |
var overlayCtx;
|
80 | |
var intervalId;
|
|
80 |
var request;
|
81 | 81 |
|
82 | 82 |
var manager = new yoob.SpriteManager();
|
83 | 83 |
|
|
97 | 97 |
manager.init(canvas);
|
98 | 98 |
ctx = canvas.getContext('2d');
|
99 | 99 |
overlayCtx = overlayCanvas.getContext('2d');
|
100 | |
var self = this;
|
101 | 100 |
|
102 | 101 |
var outside = new Rectangle();
|
103 | 102 |
outside.init(0, 0, 0, 0, canvas.width, canvas.height, '', undefined, null);
|
|
115 | 114 |
yellowRectangle.scrawlOn = overlayCtx;
|
116 | 115 |
manager.addSprite(yellowRectangle);
|
117 | 116 |
|
118 | |
intervalId = setInterval(function() { self.draw(); }, 16);
|
|
117 |
var $this = this;
|
|
118 |
var animFrame = function(time) {
|
|
119 |
$this.draw();
|
|
120 |
request = requestAnimationFrame(animFrame);
|
|
121 |
};
|
|
122 |
request = requestAnimationFrame(animFrame);
|
119 | 123 |
};
|
120 | 124 |
}
|
0 | 0 |
Multicolouralism = function() {
|
1 | 1 |
var canvas;
|
2 | 2 |
var ctx;
|
3 | |
var intervalId;
|
|
3 |
var request;
|
4 | 4 |
var rows;
|
5 | 5 |
var cols;
|
6 | 6 |
var radius;
|
|
73 | 73 |
|
74 | 74 |
var animFrame = function(time) {
|
75 | 75 |
$this.draw();
|
76 | |
requestAnimationFrame(animFrame);
|
|
76 |
request = requestAnimationFrame(animFrame);
|
77 | 77 |
};
|
78 | 78 |
|
79 | |
requestAnimationFrame(animFrame);
|
|
79 |
request = requestAnimationFrame(animFrame);
|
80 | 80 |
};
|
81 | 81 |
}
|
0 | 0 |
PrairieController = function() {
|
1 | 1 |
var canvas;
|
2 | |
var interval_id;
|
|
2 |
var request;
|
3 | 3 |
|
4 | 4 |
var img = new Image();
|
5 | 5 |
var shapes = new Array();
|
|
42 | 42 |
shapes[i] = {};
|
43 | 43 |
new_shape(i);
|
44 | 44 |
}
|
45 | |
var self = this;
|
|
45 |
var $this = this;
|
46 | 46 |
img.onload = function() {
|
47 | |
self.draw();
|
48 | |
interval_id = setInterval(self.draw, 20);
|
|
47 |
$this.draw();
|
|
48 |
var animFrame = function(time) {
|
|
49 |
$this.draw();
|
|
50 |
request = requestAnimationFrame(animFrame);
|
|
51 |
};
|
|
52 |
request = requestAnimationFrame(animFrame);
|
49 | 53 |
}
|
50 | 54 |
img.src = imgurl;
|
51 | 55 |
}
|
52 | 56 |
|
53 | 57 |
this.stop = function() {
|
54 | |
if (interval_id === undefined)
|
|
58 |
if (request === undefined)
|
55 | 59 |
return;
|
56 | |
clearInterval(interval_id);
|
57 | |
interval_id = undefined;
|
|
60 |
cancelRequestAnimationFrame(request);
|
|
61 |
request = undefined;
|
58 | 62 |
}
|
59 | 63 |
}
|
0 | 0 |
function ProgressionController(canvas) {
|
1 | 1 |
var self = {};
|
2 | 2 |
var counter;
|
3 | |
var interval_id;
|
|
3 |
var request;
|
4 | 4 |
|
5 | 5 |
self.draw = function() {
|
6 | 6 |
var ctx = canvas.getContext('2d');
|
|
28 | 28 |
self.start = function() {
|
29 | 29 |
counter = 1;
|
30 | 30 |
self.draw();
|
31 | |
interval_id = setInterval(self.draw, 50);
|
|
31 |
var animFrame = function(time) {
|
|
32 |
self.draw();
|
|
33 |
request = requestAnimationFrame(animFrame);
|
|
34 |
};
|
|
35 |
request = requestAnimationFrame(animFrame);
|
32 | 36 |
};
|
33 | 37 |
|
34 | 38 |
return self;
|