mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-20 16:56:43 +08:00
[libgdx] Clear skeleton if update fails instead of crashing.
This commit is contained in:
parent
2c6b43a9c2
commit
67f09f79ed
@ -32,6 +32,8 @@ package com.esotericsoftware.spine;
|
|||||||
import java.lang.Thread.UncaughtExceptionHandler;
|
import java.lang.Thread.UncaughtExceptionHandler;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
|
import org.lwjgl.system.Configuration;
|
||||||
|
|
||||||
import com.badlogic.gdx.ApplicationAdapter;
|
import com.badlogic.gdx.ApplicationAdapter;
|
||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.Preferences;
|
import com.badlogic.gdx.Preferences;
|
||||||
@ -53,7 +55,6 @@ import com.esotericsoftware.spine.Animation.MixBlend;
|
|||||||
import com.esotericsoftware.spine.AnimationState.AnimationStateAdapter;
|
import com.esotericsoftware.spine.AnimationState.AnimationStateAdapter;
|
||||||
import com.esotericsoftware.spine.AnimationState.TrackEntry;
|
import com.esotericsoftware.spine.AnimationState.TrackEntry;
|
||||||
import com.esotericsoftware.spine.utils.TwoColorPolygonBatch;
|
import com.esotericsoftware.spine.utils.TwoColorPolygonBatch;
|
||||||
import org.lwjgl.system.Configuration;
|
|
||||||
|
|
||||||
import java.awt.Toolkit;
|
import java.awt.Toolkit;
|
||||||
|
|
||||||
@ -195,6 +196,14 @@ public class SkeletonViewer extends ApplicationAdapter {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void clearSkeleton () {
|
||||||
|
skeleton = null;
|
||||||
|
state = null;
|
||||||
|
ui.skinList.clearItems();
|
||||||
|
ui.animationList.clearItems();
|
||||||
|
ui.statusLabel.setText("");
|
||||||
|
}
|
||||||
|
|
||||||
void setAnimation (boolean first) {
|
void setAnimation (boolean first) {
|
||||||
if (!ui.prefsLoaded) return;
|
if (!ui.prefsLoaded) return;
|
||||||
if (ui.animationList.getSelected() == null) return;
|
if (ui.animationList.getSelected() == null) return;
|
||||||
@ -266,10 +275,17 @@ public class SkeletonViewer extends ApplicationAdapter {
|
|||||||
skeleton.setupPoseSlots();
|
skeleton.setupPoseSlots();
|
||||||
|
|
||||||
delta = Math.min(delta, 0.032f) * ui.speedSlider.getValue();
|
delta = Math.min(delta, 0.032f) * ui.speedSlider.getValue();
|
||||||
state.update(delta);
|
try {
|
||||||
state.apply(skeleton);
|
state.update(delta);
|
||||||
skeleton.update(delta);
|
state.apply(skeleton);
|
||||||
skeleton.updateWorldTransform(Physics.update);
|
skeleton.update(delta);
|
||||||
|
skeleton.updateWorldTransform(Physics.update);
|
||||||
|
} catch (Throwable ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
ui.toast("Error updating skeleton.");
|
||||||
|
clearSkeleton();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
batch.begin();
|
batch.begin();
|
||||||
renderer.draw(batch, skeleton);
|
renderer.draw(batch, skeleton);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user