本文整理汇总了Java中com.esotericsoftware.spine.attachments.SkinnedMeshAttachment类的典型用法代码示例。如果您正苦于以下问题:Java SkinnedMeshAttachment类的具体用法?Java SkinnedMeshAttachment怎么用?Java SkinnedMeshAttachment使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SkinnedMeshAttachment类属于com.esotericsoftware.spine.attachments包,在下文中一共展示了SkinnedMeshAttachment类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: draw
import com.esotericsoftware.spine.attachments.SkinnedMeshAttachment; //导入依赖的package包/类
public void draw (Batch batch, Skeleton skeleton) {
boolean premultipliedAlpha = this.premultipliedAlpha;
BlendMode blendMode = null;
Array<Slot> drawOrder = skeleton.drawOrder;
for (int i = 0, n = drawOrder.size; i < n; i++) {
Slot slot = drawOrder.get(i);
Attachment attachment = slot.attachment;
if (attachment instanceof RegionAttachment) {
RegionAttachment regionAttachment = (RegionAttachment)attachment;
regionAttachment.updateWorldVertices(slot, premultipliedAlpha);
float[] vertices = regionAttachment.getWorldVertices();
BlendMode slotBlendMode = slot.data.getBlendMode();
if (slotBlendMode != blendMode) {
blendMode = slotBlendMode;
batch.setBlendFunction(blendMode.getSource(premultipliedAlpha), blendMode.getDest());
}
batch.draw(regionAttachment.getRegion().getTexture(), vertices, 0, 20);
} else if (attachment instanceof MeshAttachment || attachment instanceof SkinnedMeshAttachment) {
throw new RuntimeException("PolygonSpriteBatch is required to render meshes.");
} else if (attachment instanceof SkeletonAttachment) {
Skeleton attachmentSkeleton = ((SkeletonAttachment)attachment).getSkeleton();
if (attachmentSkeleton == null) continue;
Bone bone = slot.getBone();
Bone rootBone = attachmentSkeleton.getRootBone();
float oldScaleX = rootBone.getScaleX();
float oldScaleY = rootBone.getScaleY();
float oldRotation = rootBone.getRotation();
attachmentSkeleton.setPosition(skeleton.getX() + bone.getWorldX(), skeleton.getY() + bone.getWorldY());
rootBone.setScaleX(1 + bone.getWorldScaleX() - oldScaleX);
rootBone.setScaleY(1 + bone.getWorldScaleY() - oldScaleY);
rootBone.setRotation(oldRotation + bone.getWorldRotation());
attachmentSkeleton.updateWorldTransform();
draw(batch, attachmentSkeleton);
attachmentSkeleton.setX(0);
attachmentSkeleton.setY(0);
rootBone.setScaleX(oldScaleX);
rootBone.setScaleY(oldScaleY);
rootBone.setRotation(oldRotation);
}
}
}