mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-09 08:38:43 +08:00
[libgdx] Added SkeletonActor# and SkeletonDrawable#updateWorldTransform for subclasses to override.
This commit is contained in:
parent
a70e8f1e28
commit
9678808aaf
@ -35,6 +35,7 @@ import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||
|
||||
import com.esotericsoftware.spine.AnimationState;
|
||||
import com.esotericsoftware.spine.Skeleton;
|
||||
import com.esotericsoftware.spine.Skeleton.Physics;
|
||||
import com.esotericsoftware.spine.SkeletonRenderer;
|
||||
|
||||
/** A scene2d actor that draws a skeleton. */
|
||||
@ -69,7 +70,7 @@ public class SkeletonActor extends Actor {
|
||||
skeleton.getColor().a *= parentAlpha;
|
||||
|
||||
skeleton.setPosition(getX(), getY());
|
||||
skeleton.updateWorldTransform();
|
||||
updateWorldTransform();
|
||||
renderer.draw(batch, skeleton);
|
||||
|
||||
if (resetBlendFunction) batch.setBlendFunctionSeparate(blendSrc, blendDst, blendSrcAlpha, blendDstAlpha);
|
||||
@ -77,6 +78,10 @@ public class SkeletonActor extends Actor {
|
||||
color.a = oldAlpha;
|
||||
}
|
||||
|
||||
protected void updateWorldTransform () {
|
||||
skeleton.updateWorldTransform(Physics.update);
|
||||
}
|
||||
|
||||
public SkeletonRenderer getRenderer () {
|
||||
return renderer;
|
||||
}
|
||||
|
||||
@ -35,6 +35,7 @@ import com.badlogic.gdx.scenes.scene2d.utils.BaseDrawable;
|
||||
import com.esotericsoftware.spine.AnimationState;
|
||||
import com.esotericsoftware.spine.Skeleton;
|
||||
import com.esotericsoftware.spine.SkeletonRenderer;
|
||||
import com.esotericsoftware.spine.Skeleton.Physics;
|
||||
|
||||
/** A scene2d drawable that draws a skeleton. The animation state and skeleton must be updated each frame, or
|
||||
* {@link #update(float)} called each frame. */
|
||||
@ -64,12 +65,16 @@ public class SkeletonDrawable extends BaseDrawable {
|
||||
int blendSrcAlpha = batch.getBlendSrcFuncAlpha(), blendDstAlpha = batch.getBlendDstFuncAlpha();
|
||||
|
||||
skeleton.setPosition(x, y);
|
||||
skeleton.updateWorldTransform();
|
||||
updateWorldTransform();
|
||||
renderer.draw(batch, skeleton);
|
||||
|
||||
if (resetBlendFunction) batch.setBlendFunctionSeparate(blendSrc, blendDst, blendSrcAlpha, blendDstAlpha);
|
||||
}
|
||||
|
||||
protected void updateWorldTransform () {
|
||||
skeleton.updateWorldTransform(Physics.update);
|
||||
}
|
||||
|
||||
public SkeletonRenderer getRenderer () {
|
||||
return renderer;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user