-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAppFrame.js
More file actions
68 lines (68 loc) · 1.87 KB
/
AppFrame.js
File metadata and controls
68 lines (68 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
var AppFrame = (function () {
function AppFrame(frames, initialized) {
this.initialized = true;
this.running = false;
this.initialized = (typeof initialized != undefined) ? initialized : this.initialized;
this.setFps(frames);
}
AppFrame.blank = function () {
};
AppFrame.prototype.initialize = function () {
};
AppFrame.prototype.update = function () {
};
AppFrame.prototype.draw = function () {
};
AppFrame.prototype.exit = function () {
};
AppFrame.prototype.setFunctions = function (initialize, update, draw, exit) {
if(initialize !== undefined) {
this.initialize = initialize;
}
if(update !== undefined) {
this.update = update;
}
if(draw !== undefined) {
this.draw = draw;
}
if(exit !== undefined) {
this.exit = exit;
}
};
AppFrame.prototype.start = function () {
if(this.running === true) {
return;
}
this.running = true;
this.initialize();
this.delegate = ((function (that) {
return function () {
that.run(that);
}
})(this));
this.run(this);
};
AppFrame.prototype.stop = function () {
this.running = false;
};
AppFrame.prototype.setFps = function (fps) {
this.fps = fps;
this.sleep = (fps) ? Math.ceil(1000 / fps) : 0;
};
AppFrame.prototype.getFps = function () {
return this.fps;
};
AppFrame.prototype.run = function (that) {
if(that.running) {
if(that.initialized) {
that.update();
that.draw();
}
setTimeout(that.delegate, that.sleep);
} else {
this.exit();
}
};
return AppFrame;
})();
//@ sourceMappingURL=AppFrame.js.map