JavaScript
语言:
JaveScriptBabelCoffeeScript
确定
var hc = {
worlds: [],
startTime: null,
anim: null,
summon: function() {
for (key in arguments) {
this.worlds.push(arguments[key]);
}
},
ignite: function() {
this.startTime = new Date().getTime();
this.igniteWorlds();
this.frame();
},
frame: function() {
hc.paint(new Date().getTime());
hc.anim = window.requestAnimationFrame(hc.frame);
},
paint: function(t) {
for (key in hc.worlds) {
hc.worlds[key].world.update(t - hc.startTime);
}
},
igniteWorlds: function() {
for (key in this.worlds) {
this.worlds[key].world.ignite(this.worlds[key].args);
}
}