mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-05 06:44:56 +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.reflect.Field;
|
||||
|
||||
import org.lwjgl.system.Configuration;
|
||||
|
||||
import com.badlogic.gdx.ApplicationAdapter;
|
||||
import com.badlogic.gdx.Gdx;
|
||||
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.TrackEntry;
|
||||
import com.esotericsoftware.spine.utils.TwoColorPolygonBatch;
|
||||
import org.lwjgl.system.Configuration;
|
||||
|
||||
import java.awt.Toolkit;
|
||||
|
||||
@ -195,6 +196,14 @@ public class SkeletonViewer extends ApplicationAdapter {
|
||||
return true;
|
||||
}
|
||||
|
||||
void clearSkeleton () {
|
||||
skeleton = null;
|
||||
state = null;
|
||||
ui.skinList.clearItems();
|
||||
ui.animationList.clearItems();
|
||||
ui.statusLabel.setText("");
|
||||
}
|
||||
|
||||
void setAnimation (boolean first) {
|
||||
if (!ui.prefsLoaded) return;
|
||||
if (ui.animationList.getSelected() == null) return;
|
||||
@ -266,10 +275,17 @@ public class SkeletonViewer extends ApplicationAdapter {
|
||||
skeleton.setupPoseSlots();
|
||||
|
||||
delta = Math.min(delta, 0.032f) * ui.speedSlider.getValue();
|
||||
state.update(delta);
|
||||
state.apply(skeleton);
|
||||
skeleton.update(delta);
|
||||
skeleton.updateWorldTransform(Physics.update);
|
||||
try {
|
||||
state.update(delta);
|
||||
state.apply(skeleton);
|
||||
skeleton.update(delta);
|
||||
skeleton.updateWorldTransform(Physics.update);
|
||||
} catch (Throwable ex) {
|
||||
ex.printStackTrace();
|
||||
ui.toast("Error updating skeleton.");
|
||||
clearSkeleton();
|
||||
return;
|
||||
}
|
||||
|
||||
batch.begin();
|
||||
renderer.draw(batch, skeleton);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user