• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java SkeletonAttachment类的典型用法和代码示例

java 1次浏览

本文整理汇总了Java中com.esotericsoftware.spine.attachments.SkeletonAttachment的典型用法代码示例。如果您正苦于以下问题:Java SkeletonAttachment类的具体用法?Java SkeletonAttachment怎么用?Java SkeletonAttachment使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

SkeletonAttachment类属于com.esotericsoftware.spine.attachments包,在下文中一共展示了SkeletonAttachment类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: draw

点赞 2

import com.esotericsoftware.spine.attachments.SkeletonAttachment; //导入依赖的package包/类
@SuppressWarnings("null")
public void draw (PolygonSpriteBatch batch, Skeleton skeleton) {
	boolean premultipliedAlpha = this.premultipliedAlpha;
	BlendMode blendMode = null;

	float[] vertices = null;
	short[] triangles = 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;
		Texture texture = null;
		if (attachment instanceof RegionAttachment) {
			RegionAttachment region = (RegionAttachment)attachment;
			vertices = region.updateWorldVertices(slot, premultipliedAlpha);
			triangles = quadTriangles;
			texture = region.getRegion().getTexture();

		} else if (attachment instanceof MeshAttachment) {
			MeshAttachment mesh = (MeshAttachment)attachment;
			vertices = mesh.updateWorldVertices(slot, premultipliedAlpha);
			triangles = mesh.getTriangles();
			texture = mesh.getRegion().getTexture();

		} 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(bone.getWorldX(), bone.getWorldY());
			// rootBone.setScaleX(1 + bone.getWorldScaleX() - oldScaleX);
			// rootBone.setScaleY(1 + bone.getWorldScaleY() - oldScaleY);
			// Set shear.
			rootBone.setRotation(oldRotation + bone.getWorldRotationX());
			attachmentSkeleton.updateWorldTransform();

			draw(batch, attachmentSkeleton);

			attachmentSkeleton.setPosition(0, 0);
			rootBone.setScaleX(oldScaleX);
			rootBone.setScaleY(oldScaleY);
			rootBone.setRotation(oldRotation);
		}

		if (texture != null) {
			BlendMode slotBlendMode = slot.data.getBlendMode();
			if (slotBlendMode != blendMode) {
				blendMode = slotBlendMode;
				batch.setBlendFunction(blendMode.getSource(premultipliedAlpha), blendMode.getDest());
			}
			batch.draw(texture, vertices, 0, vertices.length, triangles, 0, triangles.length);
		}
	}
}
 

开发者ID:laurencegw,
项目名称:jenjin,
代码行数:58,
代码来源:SkeletonMeshRenderer.java

示例2: draw

点赞 2

import com.esotericsoftware.spine.attachments.SkeletonAttachment; //导入依赖的package包/类
public void draw (T batch, Skeleton skeleton) {
	boolean premultipliedAlpha = this.premultipliedAlpha;

	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;
			float[] vertices = regionAttachment.updateWorldVertices(slot, premultipliedAlpha);
			BlendMode blendMode = slot.data.getBlendMode();
			batch.setBlendFunction(blendMode.getSource(premultipliedAlpha), blendMode.getDest());
			batch.draw(regionAttachment.getRegion().getTexture(), vertices, 0, 20);

		} else if (attachment instanceof MeshAttachment) {
			throw new RuntimeException("SkeletonMeshRenderer 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(bone.getWorldX(), bone.getWorldY());
			// rootBone.setScaleX(1 + bone.getWorldScaleX() - oldScaleX);
			// rootBone.setScaleY(1 + bone.getWorldScaleY() - oldScaleY);
			// Set shear.
			rootBone.setRotation(oldRotation + bone.getWorldRotationX());
			attachmentSkeleton.updateWorldTransform();

			draw(batch, attachmentSkeleton);

			attachmentSkeleton.setX(0);
			attachmentSkeleton.setY(0);
			rootBone.setScaleX(oldScaleX);
			rootBone.setScaleY(oldScaleY);
			rootBone.setRotation(oldRotation);
		}
	}
}
 

开发者ID:laurencegw,
项目名称:jenjin,
代码行数:43,
代码来源:SkeletonRenderer.java

示例3: draw

点赞 2

import com.esotericsoftware.spine.attachments.SkeletonAttachment; //导入依赖的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

示例4: draw

点赞 2

import com.esotericsoftware.spine.attachments.SkeletonAttachment; //导入依赖的package包/类
@SuppressWarnings("null")
public void draw (PolygonSpriteBatch batch, Skeleton skeleton) {
	boolean premultipliedAlpha = this.premultipliedAlpha;

	float[] vertices = null;
	short[] triangles = 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;
		Texture texture = null;
		if (attachment instanceof RegionAttachment) {
			RegionAttachment region = (RegionAttachment)attachment;
			vertices = region.updateWorldVertices(slot, premultipliedAlpha);
			triangles = quadTriangles;
			texture = region.getRegion().getTexture();

		} else if (attachment instanceof MeshAttachment) {
			MeshAttachment mesh = (MeshAttachment)attachment;
			vertices = mesh.updateWorldVertices(slot, premultipliedAlpha);
			triangles = mesh.getTriangles();
			texture = mesh.getRegion().getTexture();

		} 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);
			// Set shear.
			rootBone.setRotation(oldRotation + bone.getWorldRotationX());
			attachmentSkeleton.updateWorldTransform();

			draw(batch, attachmentSkeleton);

			attachmentSkeleton.setPosition(0, 0);
			rootBone.setScaleX(oldScaleX);
			rootBone.setScaleY(oldScaleY);
			rootBone.setRotation(oldRotation);
		}

		if (texture != null) {
			BlendMode blendMode = slot.data.getBlendMode();
			batch.setBlendFunction(blendMode.getSource(premultipliedAlpha), blendMode.getDest());
			batch.draw(texture, vertices, 0, vertices.length, triangles, 0, triangles.length);
		}
	}
}
 

开发者ID:kotcrab,
项目名称:vis-editor,
代码行数:54,
代码来源:SkeletonMeshRenderer.java

示例5: draw

点赞 2

import com.esotericsoftware.spine.attachments.SkeletonAttachment; //导入依赖的package包/类
public void draw (T batch, Skeleton skeleton) {
	boolean premultipliedAlpha = this.premultipliedAlpha;

	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;
			float[] vertices = regionAttachment.updateWorldVertices(slot, premultipliedAlpha);
			BlendMode blendMode = slot.data.getBlendMode();
			batch.setBlendFunction(blendMode.getSource(premultipliedAlpha), blendMode.getDest());
			batch.draw(regionAttachment.getRegion().getTexture(), vertices, 0, 20);

		} else if (attachment instanceof MeshAttachment) {
			throw new RuntimeException("SkeletonMeshRenderer 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);
			// Set shear.
			rootBone.setRotation(oldRotation + bone.getWorldRotationX());
			attachmentSkeleton.updateWorldTransform();

			draw(batch, attachmentSkeleton);

			attachmentSkeleton.setX(0);
			attachmentSkeleton.setY(0);
			rootBone.setScaleX(oldScaleX);
			rootBone.setScaleY(oldScaleY);
			rootBone.setRotation(oldRotation);
		}
	}
}
 

开发者ID:kotcrab,
项目名称:vis-editor,
代码行数:43,
代码来源:SkeletonRenderer.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)