Fix Spine animations without default skin, paths in mesh attachments and optimize SpineActor
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Submodule h2d-libgdx-spine-extension updated: 2e3d05e227...c6e614a3db
@@ -30,6 +30,10 @@ public class SpineDrawable extends BaseDrawable {
|
||||
this.skeleton = skeleton;
|
||||
AnimationStateData animationStateData = new AnimationStateData(skeleton.getData());
|
||||
animationState = new AnimationState(animationStateData);
|
||||
if (skeleton.getData().getDefaultSkin() == null) {
|
||||
skeleton.setSkin(skeleton.getData().getSkins().get(0));
|
||||
skeleton.setSlotsToSetupPose();
|
||||
}
|
||||
|
||||
computeBoundBox();
|
||||
|
||||
|
||||
@@ -34,10 +34,11 @@ public class SpineActor extends Actor {
|
||||
this.renderer = new SkeletonRenderer();
|
||||
this.animationName = animationName;
|
||||
initSkeletonData();
|
||||
initSpine();
|
||||
scaleChanged();
|
||||
}
|
||||
|
||||
private void computeBoundBox() {
|
||||
skeleton.setPosition(0, 0);
|
||||
skeleton.updateWorldTransform();
|
||||
|
||||
Array<Slot> drawOrder = skeleton.getDrawOrder();
|
||||
@@ -79,15 +80,15 @@ public class SpineActor extends Actor {
|
||||
SpineDataObject spineDataObject = (SpineDataObject) irr.getExternalItemType(SpineItemType.SPINE_TYPE, animationName);
|
||||
skeletonJson = spineDataObject.skeletonJson;
|
||||
skeletonData = spineDataObject.skeletonData;
|
||||
}
|
||||
|
||||
private void initSpine() {
|
||||
skeleton = new Skeleton(skeletonData);
|
||||
skeleton.setScale(getScaleX(), getScaleY());
|
||||
AnimationStateData stateData = new AnimationStateData(skeletonData);
|
||||
state = new AnimationState(stateData);
|
||||
computeBoundBox();
|
||||
skeleton = new Skeleton(skeletonData);
|
||||
|
||||
setAnimation(skeletonData.getAnimations().get(0).getName());
|
||||
if (skeletonData.getDefaultSkin() == null) {
|
||||
skeleton.setSkin(skeletonData.getSkins().get(0));
|
||||
skeleton.setSlotsToSetupPose();
|
||||
}
|
||||
}
|
||||
|
||||
public Array<Animation> getAnimations() {
|
||||
@@ -103,9 +104,9 @@ public class SpineActor extends Actor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setScale(float scale) {
|
||||
super.setScale(scale);
|
||||
initSpine();
|
||||
protected void scaleChanged() {
|
||||
skeleton.setScale(getScaleX(), getScaleY());
|
||||
computeBoundBox();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -122,12 +123,16 @@ public class SpineActor extends Actor {
|
||||
super.draw(batch, parentAlpha);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void positionChanged() {
|
||||
skeleton.setPosition(getX() - minX, getY() - minY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void act(float delta) {
|
||||
skeleton.updateWorldTransform(); //
|
||||
state.update(delta);
|
||||
state.apply(skeleton);
|
||||
skeleton.setPosition(getX() - minX, getY() - minY);
|
||||
super.act(delta);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user