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


Java PolygonSpriteBatch.setBlendFunction方法代码示例

本文整理汇总了Java中com.badlogic.gdx.graphics.g2d.PolygonSpriteBatch.setBlendFunction方法的典型用法代码示例。如果您正苦于以下问题:Java PolygonSpriteBatch.setBlendFunction方法的具体用法?Java PolygonSpriteBatch.setBlendFunction怎么用?Java PolygonSpriteBatch.setBlendFunction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.badlogic.gdx.graphics.g2d.PolygonSpriteBatch的用法示例。


在下文中一共展示了PolygonSpriteBatch.setBlendFunction方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: draw

import com.badlogic.gdx.graphics.g2d.PolygonSpriteBatch; //导入方法依赖的package包/类
@Override
public void draw(GameMapRenderer renderer, float deltaTime) {
	super.draw(renderer, deltaTime);
	if (!hasSprite()) {
		PlayerCharacterController controller = gameState.getPlayerCharacterController();
		Tool activeTool = controller.getActiveTool();
		
		PolygonSpriteBatch spriteBatch = renderer.getSpriteBatch();
		int src = spriteBatch.getBlendSrcFunc();
		int dst = spriteBatch.getBlendDstFunc();
		if (src != GL20.GL_SRC_ALPHA || dst != GL20.GL_ONE) {
			spriteBatch.setBlendFunction(GL20.GL_SRC_ALPHA, GL20.GL_ONE);
		}
		spriteBatch.setColor(isHovered() && activeTool == Tool.DISARM ? ColorUtil.GREEN_SEVENFIVE : ColorUtil.RED_SEVENFIVE);
		polygonRenderer.render(spriteBatch);
		if (src != GL20.GL_SRC_ALPHA || dst != GL20.GL_ONE) {
			spriteBatch.setBlendFunction(src, dst);
		}
	}
}
 
开发者ID:mganzarcik,项目名称:fabulae,代码行数:21,代码来源:UsableGameObject.java

示例2: draw

import com.badlogic.gdx.graphics.g2d.PolygonSpriteBatch; //导入方法依赖的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

示例3: draw

import com.badlogic.gdx.graphics.g2d.PolygonSpriteBatch; //导入方法依赖的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


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