Fix json animation for single animation

This commit is contained in:
John Alanbrook 2024-04-16 12:36:26 -05:00
parent c368b81216
commit 127569ee03
3 changed files with 14 additions and 1 deletions

View file

@ -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];

View file

@ -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)

View file

@ -365,6 +365,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;