mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +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.AnimationState;
|
||||||
import com.esotericsoftware.spine.Skeleton;
|
import com.esotericsoftware.spine.Skeleton;
|
||||||
|
import com.esotericsoftware.spine.Skeleton.Physics;
|
||||||
import com.esotericsoftware.spine.SkeletonRenderer;
|
import com.esotericsoftware.spine.SkeletonRenderer;
|
||||||
|
|
||||||
/** A scene2d actor that draws a skeleton. */
|
/** A scene2d actor that draws a skeleton. */
|
||||||
@ -69,7 +70,7 @@ public class SkeletonActor extends Actor {
|
|||||||
skeleton.getColor().a *= parentAlpha;
|
skeleton.getColor().a *= parentAlpha;
|
||||||
|
|
||||||
skeleton.setPosition(getX(), getY());
|
skeleton.setPosition(getX(), getY());
|
||||||
skeleton.updateWorldTransform();
|
updateWorldTransform();
|
||||||
renderer.draw(batch, skeleton);
|
renderer.draw(batch, skeleton);
|
||||||
|
|
||||||
if (resetBlendFunction) batch.setBlendFunctionSeparate(blendSrc, blendDst, blendSrcAlpha, blendDstAlpha);
|
if (resetBlendFunction) batch.setBlendFunctionSeparate(blendSrc, blendDst, blendSrcAlpha, blendDstAlpha);
|
||||||
@ -77,6 +78,10 @@ public class SkeletonActor extends Actor {
|
|||||||
color.a = oldAlpha;
|
color.a = oldAlpha;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void updateWorldTransform () {
|
||||||
|
skeleton.updateWorldTransform(Physics.update);
|
||||||
|
}
|
||||||
|
|
||||||
public SkeletonRenderer getRenderer () {
|
public SkeletonRenderer getRenderer () {
|
||||||
return renderer;
|
return renderer;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -35,6 +35,7 @@ import com.badlogic.gdx.scenes.scene2d.utils.BaseDrawable;
|
|||||||
import com.esotericsoftware.spine.AnimationState;
|
import com.esotericsoftware.spine.AnimationState;
|
||||||
import com.esotericsoftware.spine.Skeleton;
|
import com.esotericsoftware.spine.Skeleton;
|
||||||
import com.esotericsoftware.spine.SkeletonRenderer;
|
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
|
/** A scene2d drawable that draws a skeleton. The animation state and skeleton must be updated each frame, or
|
||||||
* {@link #update(float)} called each frame. */
|
* {@link #update(float)} called each frame. */
|
||||||
@ -64,12 +65,16 @@ public class SkeletonDrawable extends BaseDrawable {
|
|||||||
int blendSrcAlpha = batch.getBlendSrcFuncAlpha(), blendDstAlpha = batch.getBlendDstFuncAlpha();
|
int blendSrcAlpha = batch.getBlendSrcFuncAlpha(), blendDstAlpha = batch.getBlendDstFuncAlpha();
|
||||||
|
|
||||||
skeleton.setPosition(x, y);
|
skeleton.setPosition(x, y);
|
||||||
skeleton.updateWorldTransform();
|
updateWorldTransform();
|
||||||
renderer.draw(batch, skeleton);
|
renderer.draw(batch, skeleton);
|
||||||
|
|
||||||
if (resetBlendFunction) batch.setBlendFunctionSeparate(blendSrc, blendDst, blendSrcAlpha, blendDstAlpha);
|
if (resetBlendFunction) batch.setBlendFunctionSeparate(blendSrc, blendDst, blendSrcAlpha, blendDstAlpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void updateWorldTransform () {
|
||||||
|
skeleton.updateWorldTransform(Physics.update);
|
||||||
|
}
|
||||||
|
|
||||||
public SkeletonRenderer getRenderer () {
|
public SkeletonRenderer getRenderer () {
|
||||||
return renderer;
|
return renderer;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user