- Modifié
Random IndexOutOfBoundsException
In my developing game, sometime it show this error:
" Exception in thread "LWJGL Application" java.lang.IndexOutOfBoundsException: index can't be >= size: 1 >= 1
at com.badlogic.gdx.utils.Array.get(Array.java:127)
at com.esotericsoftware.spine.AnimationState.apply(AnimationState.java:118)"
I am trying to solve it but not success. It seem occur when game play call many to showEnemyAttackSign() function.
This is main execution code:
private IceEffectActor attackSign;
private AnimationStateAdapter listener;
private boolean attackSignFinish = true;
private int attackSignCnt = 0;
private final synchronized void showEnemyAttackSign() {
if(attackSignCnt==0){
attackSignFinish = false;
attackSignCnt++;
}
if(attackSign !=null&&!attackSignFinish){
attackSignFinish = true;
attackSign.setVisible(true);
attackSign.setAnim("ice", false);
listener = new AnimationStateAdapter() {
@Override
public void event (int trackIndex, Event event) {
// Inspect and respond to the event here.
if (event!=null){
if (event.getString().equalsIgnoreCase("end_ice_fx")) {
Gdx.app.error("BattleStage",
"Event finish: " + event.getString());
attackSign.animState.removeListener(listener);
listener = null;
attackSignCnt
---
;
Gdx.app.error("BattleStage attackSignCnt finish",attackSignCnt+"");
if(attackSignCnt==0){
attackSignFinish = true;
}
else{
attackSignCnt
---
;
showEnemyAttackSign();
attackSignFinish = false;
}
}
}
}
};
attackSign.animState.addListener(listener);
}
else{
attackSignCnt++;
}
}
This is Actor class
public class IceEffectActor extends Actor {
public Skeleton getSkeleton() {
return skeleton;
}
private Skeleton skeleton;
private SkeletonRenderer skeletonRenderer;
public AnimationState animState;
public IceEffectActor() {
setPosition(0.0f, 600.0f);
loadAnimation();
}
private void loadAnimation() {
AnimationStateData stateData = new AnimationStateData(Assets.iceFXData);
animState = new AnimationState(stateData);
skeleton = new Skeleton(Assets.iceFXData);
// skeleton.setToSetupPose();
skeleton.updateWorldTransform();
skeletonRenderer = new SkeletonRenderer();
}
public void setAnim(String name, boolean repeat){
animState.setAnimation(0, name, repeat);
}
@Override
public void act(float delta) {
skeleton.setX(getX() + getWidth() / 2.0f);
skeleton.setY(getY());
skeleton.update(delta);
skeleton.updateWorldTransform();
animState.update(delta);
animState.apply(skeleton);
super.act(delta);
}
@Override
public void draw(Batch batch, float parentAlpha) {
skeleton.getColor().a = parentAlpha;
skeletonRenderer.draw(batch, skeleton);
super.draw(batch, parentAlpha);
}
}
Anyone can help me, or give a hint?
I email support, open issue on Github and post here but get nothing respond from Esotericsoftware :bang: .
@Nate can you help me?
Sorry that we have not gotten back to you on this issue.
I'll make sure to poke Nate and see if he can take a look at it. I'm unfortunately not a programmer and can't help you.
Shiu a écritSorry that we have not gotten back to you on this issue.
I'll make sure to poke Nate and see if he can take a look at it. I'm unfortunately not a programmer and can't help you.
Seem Nate too busy on other project, I also submit issue on Github months ago https://github.com/EsotericSoftware/spine-runtimes/issues/464
Spine v3 has been a huge workload and we hope to release it soon. Focus is on Spine not any other projects
at com.esotericsoftware.spine.AnimationState.apply(AnimationState.java:118)
AnimationState.java:118 is this line:
listeners.get(iii).event(i, event);
You probably shouldn't tamper with the listener array while it's handling the call. That's my guess.
If that's not it, take a closer look at the linked AnimationState.java line. You can probably understand it better as a libGDX user.
More discussion here:
https://github.com/EsotericSoftware/spine-runtimes/issues/464