How to use SkeletonJson.readSkeletonData?

582 Views Asked by At

I Got a problem when I used SkeletonJson.readSkeletonData in my code.

public void create() {
    camera = new OrthographicCamera();
    batch = new PolygonSpriteBatch(); // Required to render meshes. SpriteBatch can't render meshes.
    renderer = new SkeletonRenderer();
    renderer.setPremultipliedAlpha(true);
    debugRenderer = new SkeletonRendererDebug();
    debugRenderer.setMeshTriangles(false);
    debugRenderer.setRegionAttachments(false);
    debugRenderer.setMeshHull(false);

    atlas = new TextureAtlas(Gdx.files.internal("raptor/raptor.atlas"));
    SkeletonJson json = new SkeletonJson(atlas); // This loads skeleton JSON data, which is stateless.
    json.setScale(0.5f); // Load the skeleton at 50% the size it was in Spine.
    SkeletonData skeletonData = json.readSkeletonData(Gdx.files.internal("raptor/raptor.json"));

    skeleton = new Skeleton(skeletonData); // Skeleton holds skeleton state (bone positions, slot attachments, etc).
    skeleton.setPosition(250, 20);

    AnimationStateData stateData = new AnimationStateData(skeletonData); // Defines mixing (crossfading) between animations.

    state = new AnimationState(stateData); // Holds the animation state for a skeleton (current animation, time, etc).
    state.setTimeScale(0.6f); // Slow all animations down to 60% speed.

    // Queue animations on tracks 0 and 1.
    state.setAnimation(0, "walk", true);

    state.addAnimation(1, "gun-grab", false, 2); // Keys in higher tracks override the pose from lower tracks.
}

Exception message is as follow.

enter image description here

1

There are 1 best solutions below

1
On

It seems the code fails in the line:

SkeletonData skeletonData = 
    json.readSkeletonData(Gdx.files.internal("raptor/raptor.json"));

I assume the problem falls inside raptor.json. Check it's well formed