List of usage examples for com.badlogic.gdx.graphics.g2d Batch draw
public void draw(TextureRegion region, float width, float height, Affine2 transform);
From source file:com.agateau.pixelwheels.racer.SkidmarksRenderer.java
License:Open Source License
private void drawSkidmark(Batch batch, Vector2 pos1, Vector2 pos2, float alpha1, float alpha2) { TextureRegion region = mAssets.skidmark; float c = Color.toFloatBits(1, 1, 1, alpha1); float c2 = Color.toFloatBits(1, 1, 1, alpha2); float u = region.getU(); float v = region.getV(); float u2 = region.getU2(); float v2 = region.getV2(); /*//from w w w .jav a 2s . c o m 0 3 x----------x ^ | | | pos1 x x pos2 | thickness | | x----------x 1 2 */ float x0 = pos1.x + mThickX1; float y0 = pos1.y + mThickY1; float x1 = pos1.x - mThickX1; float y1 = pos1.y - mThickY1; float x2 = pos2.x - mThickX2; float y2 = pos2.y - mThickY2; float x3 = pos2.x + mThickX2; float y3 = pos2.y + mThickY2; initVertex(0, x0, y0, c, u, v); initVertex(1, x1, y1, c, u2, v); initVertex(2, x2, y2, c2, u2, v2); initVertex(3, x3, y3, c2, u, v2); batch.draw(region.getTexture(), mVertices, 0, mVertices.length); }
From source file:com.company.minery.utils.spine.SkeletonRenderer.java
License:Open Source License
public void draw(Batch batch, Skeleton skeleton) { boolean premultipliedAlpha = this.premultipliedAlpha; int srcFunc = premultipliedAlpha ? GL20.GL_ONE : GL20.GL_SRC_ALPHA; batch.setBlendFunction(srcFunc, GL20.GL_ONE_MINUS_SRC_ALPHA); boolean additive = false; Array<Slot> drawOrder = skeleton.drawOrder; for (int i = 0, n = drawOrder.size; i < n; i++) { Slot slot = drawOrder.get(i);//from w ww . jav a 2 s. c om Attachment attachment = slot.attachment; if (attachment instanceof RegionAttachment) { RegionAttachment regionAttachment = (RegionAttachment) attachment; regionAttachment.updateWorldVertices(slot, premultipliedAlpha); float[] vertices = regionAttachment.getWorldVertices(); if (slot.data.getAdditiveBlending() != additive) { additive = !additive; if (additive) batch.setBlendFunction(srcFunc, GL20.GL_ONE); else batch.setBlendFunction(srcFunc, GL20.GL_ONE_MINUS_SRC_ALPHA); } 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); } } }
From source file:com.dongbat.game.stage.RadialSprite.java
public void draw(final Batch batch, final float x, final float y, float width, float height, final float angle) { if (width < 0) { scaleX = -1f;/*from w w w . java 2 s . c o m*/ width = -width; } if (height < 0) { scaleY = -1f; height = -height; } calculate(x, y, width, height, angle, u1, v1, u2, v2); batch.draw(texture, verts, 0, 20 * draw); }
From source file:com.trgk.touchwave.tgengine.ui.TGPrimitive.java
License:Open Source License
public static void drawLine(Batch batch, float x0, float y0, float x1, float y1, float lineWidth, Color color) { batch.setColor(color);// w w w. java2 s . c om float dv_perp_x = -(y1 - y0); float dv_perp_y = x1 - x0; float dv_perp_length = (float) Math.sqrt(dv_perp_x * dv_perp_x + dv_perp_y * dv_perp_y); dv_perp_x /= dv_perp_length; dv_perp_y /= dv_perp_length; Affine2 transform = new Affine2(); transform.m00 = x1 - x0; transform.m10 = y1 - y0; transform.m01 = dv_perp_x * lineWidth * 2; transform.m11 = dv_perp_y * lineWidth * 2; transform.m02 = x0 - dv_perp_x * lineWidth; transform.m12 = y0 - dv_perp_y * lineWidth; batch.draw(TGResources.getInstance().rectTextureRegion, 1, 1, transform); }
From source file:de.homelab.madgaksha.lotsofbs.bettersprite.CroppableSprite.java
License:Apache License
public void draw(Batch batch) { batch.draw(getTexture(), getVertices(), 0, SPRITE_SIZE); }
From source file:net.mwplay.cocostudio.ui.particleutil.CCParticleActor.java
License:Apache License
protected void drawParticles(Batch batch) { int srcFunc = batch.getBlendSrcFunc(); int dstFunc = batch.getBlendDstFunc(); batch.setBlendFunction(blendSrc, blendDst); //System.out.println("_particleCount:"+_particleCount); for (int i = 0; i < _particleCount; i++) { batch.draw(m_pTexture, vertices[i], 0, 20); }// w ww. j a v a2 s. c o m batch.setBlendFunction(srcFunc, dstFunc); // batch.setBlendFunction(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA); }
From source file:sg.atom2d.game2d.graphics.anim.spine.skeleton.SkeletonRenderer.java
License:Open Source License
public void draw(Batch batch, Skeleton skeleton) { boolean premultipliedAlpha = this.premultipliedAlpha; int srcFunc = premultipliedAlpha ? GL11.GL_ONE : GL11.GL_SRC_ALPHA; batch.setBlendFunction(srcFunc, GL11.GL_ONE_MINUS_SRC_ALPHA); boolean additive = false; Array<Slot> drawOrder = skeleton.drawOrder; for (int i = 0, n = drawOrder.size; i < n; i++) { Slot slot = drawOrder.get(i);// w w w . ja v a 2 s .c om Attachment attachment = slot.attachment; if (attachment instanceof RegionAttachment) { RegionAttachment regionAttachment = (RegionAttachment) attachment; regionAttachment.updateWorldVertices(slot, premultipliedAlpha); float[] vertices = regionAttachment.getWorldVertices(); if (slot.data.getAdditiveBlending() != additive) { additive = !additive; if (additive) { batch.setBlendFunction(srcFunc, GL11.GL_ONE); } else { batch.setBlendFunction(srcFunc, GL11.GL_ONE_MINUS_SRC_ALPHA); } } batch.draw(regionAttachment.getRegion().getTexture(), vertices, 0, 20); } 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.setX(bone.getWorldX()); attachmentSkeleton.setY(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); } } }
From source file:stu.tnt.gdx.graphics.graphics2d.SpriteA.java
License:Apache License
public void draw(Batch spriteBatch) { spriteBatch.draw(mCurrentTexture, getVertices(), 0, SPRITE_SIZE); }