Revert loading mechanism for nicer syntax

feature/coffeescript
Sven Slootweg 10 years ago
parent 709b1a9f19
commit 808f8ecd17

@ -1490,12 +1490,14 @@ ResourceManager = (function() {
if (finished_callback == null) {
finished_callback = (function() {});
}
return this.do_preload(1, (function() {}), finished_callback);
return this.do_preload(1, (function() {}), finished_callback.bind(this));
};
ResourceManager.prototype.load = function() {
var _ref, _ref1;
return this.do_preload(2, this.updateProgress, (_ref = (_ref1 = this.onLoad) != null ? _ref1.bind(this) : void 0) != null ? _ref : (function() {}));
ResourceManager.prototype.load = function(finished_callback) {
if (finished_callback == null) {
finished_callback = (function() {});
}
return this.do_preload(2, this.updateProgress, finished_callback.bind(this));
};
return ResourceManager;

@ -37,7 +37,7 @@ $(->
engine.setPreloadScene(engine.createScene("loader"))
engine.setInitialScene(engine.createScene("main"))
manager.onLoad = ->
manager.load ->
# Game asset initialization...
engine.createSprite("cursor", "images/cursor.png")
@ -112,7 +112,5 @@ $(->
# Let's go!
engine.start()
manager.load()
)

@ -22,7 +22,7 @@
engine.addCanvas($("#gamecanvas"));
engine.setPreloadScene(engine.createScene("loader"));
engine.setInitialScene(engine.createScene("main"));
manager.onLoad = function() {
return manager.load(function() {
var cursor, diamond;
engine.createSprite("cursor", "images/cursor.png");
engine.createSprite("diamond", "images/diamond.png");
@ -98,8 +98,7 @@
return _results;
};
return engine.start();
};
return manager.load();
});
});
});
})();

@ -81,9 +81,9 @@ class ResourceManager
prepare: (finished_callback = (->)) =>
# This performs a stage 1 preload, loading the initial assets required for displaying the preload screen.
@do_preload(1, (->), finished_callback)
@do_preload(1, (->), finished_callback.bind(this))
load: () =>
load: (finished_callback = (->)) =>
# This performs the stage 2 preload; it will load the actual game assets.
@do_preload(2, @updateProgress, @onLoad?.bind(this) ? (->))
@do_preload(2, @updateProgress, finished_callback.bind(this))
Loading…
Cancel
Save