当前位置: 首页>>代码示例>>Java>>正文


Java SkinnedMeshAttachment类代码示例

本文整理汇总了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);
		}
	}
}
 
开发者ID:saltares,项目名称:libgdxjam,代码行数:47,代码来源:SkeletonRenderer.java


注:本文中的com.esotericsoftware.spine.attachments.SkinnedMeshAttachment类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。