Skip to content

Commit

Permalink
Merge pull request #75 from litwak913/json-skel
Browse files Browse the repository at this point in the history
Fixed crash cuased by loading json skeleton
  • Loading branch information
isHarryh authored Sep 2, 2024
2 parents a677e5e + 92fabd5 commit fdf683f
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions core/src/cn/harryh/arkpets/ArkChar.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,16 @@ public ArkChar(ArkConfig config, float scale) {
// Load atlas
TextureAtlas atlas = new TextureAtlas(Gdx.files.internal(path2atlas));
// Load skel (use SkeletonJson instead of SkeletonBinary if the file type is JSON)
SkeletonBinary binary = new SkeletonBinary(atlas);
binary.setScale(scale);
skeletonData = binary.readSkeletonData(Gdx.files.internal(path2skel));
try {
SkeletonBinary binary = new SkeletonBinary(atlas);
binary.setScale(scale);
skeletonData = binary.readSkeletonData(Gdx.files.internal(path2skel));
} catch (Exception e) {
Logger.warn("Character", "Failed to load skeleton, trying load as json");
SkeletonJson json = new SkeletonJson(atlas);
json.setScale(scale);
skeletonData = json.readSkeletonData(Gdx.files.internal(path2skel));
}
} catch (SerializationException | GdxRuntimeException e) {
Logger.error("Character", "The model asset may be inaccessible, details see below.", e);
throw new RuntimeException("Launch ArkPets failed, the model asset may be inaccessible.");
Expand Down

0 comments on commit fdf683f

Please sign in to comment.