本文整理汇总了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);
}
}
}
示例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);
}
}
}
示例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);
}
}
}