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) { if (finished_callback == null) {
finished_callback = (function() {}); 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() { ResourceManager.prototype.load = function(finished_callback) {
var _ref, _ref1; if (finished_callback == null) {
return this.do_preload(2, this.updateProgress, (_ref = (_ref1 = this.onLoad) != null ? _ref1.bind(this) : void 0) != null ? _ref : (function() {})); finished_callback = (function() {});
}
return this.do_preload(2, this.updateProgress, finished_callback.bind(this));
}; };
return ResourceManager; return ResourceManager;

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

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

@ -81,9 +81,9 @@ class ResourceManager
prepare: (finished_callback = (->)) => prepare: (finished_callback = (->)) =>
# This performs a stage 1 preload, loading the initial assets required for displaying the preload screen. # 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. # 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