diff options
author | Alex Xu <alex_y_xu@yahoo.ca> | 2013-07-13 13:28:16 -0400 |
---|---|---|
committer | Alex Xu <alex_y_xu@yahoo.ca> | 2013-07-13 13:28:16 -0400 |
commit | 7d93ca6b9b7c899ff4f6d3173d8fc4ca551ebf30 (patch) | |
tree | 727b57256b25d2839bdadb8b3ae724e0d2ae34f7 | |
parent | 07e021baaad873f1f96936ed611f236f5e80544f (diff) | |
download | html5ks-7d93ca6b9b7c899ff4f6d3173d8fc4ca551ebf30.tar.xz html5ks-7d93ca6b9b7c899ff4f6d3173d8fc4ca551ebf30.zip |
Fix imachine imenu, seen_scenes: runInst after fork
-rw-r--r-- | www/js/api.js | 14 | ||||
-rw-r--r-- | www/js/imachine.js | 10 |
2 files changed, 15 insertions, 9 deletions
diff --git a/www/js/api.js b/www/js/api.js index 4aebde1..5b494ab 100644 --- a/www/js/api.js +++ b/www/js/api.js @@ -30,7 +30,6 @@ window.html5ks.api = { return deferred.promise; }, play: function (channel, name, fade) { - // TODO: fade var deferred = when.defer(), audio = html5ks.elements.audio[channel]; audio.src = "dump/" + (channel === "music" ? "bgm/" + html5ks.data.music[name] + ".ogg" : html5ks.data.sfx[name]); @@ -202,11 +201,14 @@ window.html5ks.api = { bgright: { xpos: 0.6, xanchor: 0.5, ypos: 1.0, yanchor: 1.0 } }; var pos = positions[location]; - el.style.left = pos.xpos * 800 + "px"; - el.style.top = pos.ypos * 600 + "px"; - el.style.marginLeft = "-" + pos.xanchor * el.width + "px"; - el.style.marginTop = "-" + pos.yanchor * el.height + "px"; - el.style.display = "block"; + // TODO: implement transitions + if (pos) { + el.style.left = pos.xpos * 800 + "px"; + el.style.top = pos.ypos * 600 + "px"; + el.style.marginLeft = "-" + pos.xanchor * el.width + "px"; + el.style.marginTop = "-" + pos.yanchor * el.height + "px"; + el.style.display = "block"; + } } deferred.resolve(); }; diff --git a/www/js/imachine.js b/www/js/imachine.js index a256019..b6117f7 100644 --- a/www/js/imachine.js +++ b/www/js/imachine.js @@ -19,6 +19,7 @@ html5ks.imachine = (function () { console.log(inst); switch (typeof inst) { case "undefined": + deferred.resolve(); break; case "string": // jump_out if (!html5ks.data.imachine[inst]) { @@ -44,15 +45,18 @@ html5ks.imachine = (function () { case "imenu": html5ks.api.menu(args[0]).then(function (choice) { var next = args[1][choice] || args[1].else; - html5ks.imachine.run(typeof next[0] === "string" ? [next] : next); + return html5ks.imachine.run(typeof next[0] === "string" ? [next] : next).then(runInst); }); break; case "seen_scene": + var next; if (this.seen_scene(inst[1])) { - this.run(inst[2]); + next = inst[2]; } else { - this.run(inst[3]); + next = inst[3]; } + // TODO: there's probably an easier way to do this + this.run(typeof next[0] === "string" ? [next] : next).then(runInst); break; case "attraction": if (typeof inst[2] === "number") { |