0

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

Sergi Juanola
  • 6,531
  • 8
  • 56
  • 93
  • I do not know if it's because of the version of spine-libgdx. – Fangzhi Huang Aug 03 '17 at 13:25
  • Please, try always copying the code of the question, especially where the stacktrace says it fails, and the exception itself (to avoid imgur deleting it in the future and making it easy to be searched). Aside from that, it seems you're looping through an array and moving outside of it. Check for a `for` that you end too late (for instance, `index <= array.size()`) – Sergi Juanola Aug 03 '17 at 13:32

1 Answers1

0

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

Sergi Juanola
  • 6,531
  • 8
  • 56
  • 93