diff --git a/scripts/components.js b/scripts/components.js index 712a400..ec21253 100644 --- a/scripts/components.js +++ b/scripts/components.js @@ -302,7 +302,7 @@ SpriteAnim.aseprite = function(path) { function aseframeset2anim(frameset, meta) { var anim = {}; anim.frames = []; - anim.path = path.dir() + "/" + meta.image; + anim.path = path.folder() + meta.image; var dim = meta.size; var ase_make_frame = function(ase_frame) { @@ -329,6 +329,10 @@ SpriteAnim.aseprite = function(path) { var anims = {}; var frames = Array.isArray(data.frames) ? data.frames : Object.values(data.frames); var f = 0; + if (data.meta.frameTags.length === 0) { + anims[0] = aseframeset2anim(frames, data.meta); + return anims; + } for (var tag of data.meta.frameTags) { anims[tag.name] = aseframeset2anim(frames.slice(tag.from, tag.to+1), data.meta); anims[f] = anims[tag.name]; diff --git a/scripts/engine.js b/scripts/engine.js index 45cdf9c..d914e58 100644 --- a/scripts/engine.js +++ b/scripts/engine.js @@ -15,6 +15,14 @@ Object.defineProperty(String.prototype, 'dir', { } }); +Object.defineProperty(String.prototype, 'folder', { + value: function() { + var dir = this.dir(); + if (!dir) return ""; + else return dir + "/"; + } +}); + globalThis.Resources = {}; Resources.replpath = function(str, path) diff --git a/source/engine/jsffi.c b/source/engine/jsffi.c index 3b8e9a3..50dca9d 100644 --- a/source/engine/jsffi.c +++ b/source/engine/jsffi.c @@ -370,6 +370,7 @@ JSValue vecarr2js(HMM_Vec2 *points, int n) { int js_print_exception(JSValue v) { + if (!js) return 0; #ifndef NDEBUG if (!JS_IsException(v)) return 0;