List of usage examples for com.badlogic.gdx.graphics.g2d Batch draw
public void draw(Texture texture, float x, float y, float originX, float originY, float width, float height, float scaleX, float scaleY, float rotation, int srcX, int srcY, int srcWidth, int srcHeight, boolean flipX, boolean flipY);
From source file:com.agateau.pixelwheels.racescreen.Helicopter.java
License:Open Source License
private void drawFrameBuffer(Batch batch, float offset) { final float U = Constants.UNIT_FOR_PIXEL; int w = mFrameBuffer.getWidth(); int h = mFrameBuffer.getHeight(); Texture texture = mFrameBuffer.getColorBufferTexture(); batch.draw(texture, // dst getX() - w * U / 2 + offset, getY() - BODY_CENTER.y * U - offset, // origin w * U / 2, BODY_CENTER.y * U, // dst size w * U, h * U,/* w w w.j a v a 2s. c o m*/ // scale 1, 1, // rotation mAngle - 90, // src 0, 0, w, h, // flips false, true); }
From source file:com.bladecoder.engine.util.RectangleRenderer.java
License:Apache License
public static void draw(Batch batch, float posX, float posY, float width, float height, Color color) { if (texture == null) texture = makePixel();/* w w w . j a va 2s. c o m*/ Color tmp = batch.getColor(); batch.setColor(color); batch.draw(texture, posX, posY, 0, 0, width, height, 1, 1, 0, 0, 0, 1, 1, false, false); batch.setColor(tmp); }
From source file:com.ixeption.libgdx.transitions.impl.AlphaFadingTransition.java
License:Apache License
@Override public void render(Batch batch, Texture currentScreenTexture, Texture nextScreenTexture, float alpha) { alpha = Interpolation.fade.apply(alpha); batch.begin();//from w w w. j a v a2 s. c o m batch.setColor(1, 1, 1, 1); batch.draw(currentScreenTexture, 0, 0, 0, 0, currentScreenTexture.getWidth(), currentScreenTexture.getHeight(), 1, 1, 0, 0, 0, currentScreenTexture.getWidth(), currentScreenTexture.getHeight(), false, true); batch.setColor(1, 1, 1, alpha); batch.draw(nextScreenTexture, 0, 0, 0, 0, nextScreenTexture.getWidth(), nextScreenTexture.getHeight(), 1, 1, 0, 0, 0, nextScreenTexture.getWidth(), nextScreenTexture.getHeight(), false, true); batch.end(); }
From source file:com.ixeption.libgdx.transitions.impl.ColorFadeTransition.java
License:Apache License
@Override public void render(Batch batch, Texture currentScreenTexture, Texture nextScreenTexture, float percent) { float width = currentScreenTexture.getWidth(); float height = currentScreenTexture.getHeight(); float x = 0;//ww w . ja v a2s. c o m float y = 0; if (interpolation != null) percent = interpolation.apply(percent); batch.begin(); float fade = percent * 2; if (fade > 1.0f) { fade = 1.0f - (percent * 2 - 1.0f); color.a = 1.0f - fade; batch.setColor(color); batch.draw(nextScreenTexture, 0, 0, width / 2, height / 2, nextScreenTexture.getWidth(), nextScreenTexture.getHeight(), 1, 1, 0, 0, 0, nextScreenTexture.getWidth(), nextScreenTexture.getHeight(), false, true); } else { color.a = 1.0f - fade; batch.setColor(color); batch.draw(currentScreenTexture, 0, 0, width / 2, height / 2, width, height, 1, 1, 0, 0, 0, (int) width, (int) height, false, true); } color.a = fade; batch.setColor(color); batch.draw(texture, 0, 0, width, height); batch.end(); batch.setColor(Color.WHITE); }
From source file:com.ixeption.libgdx.transitions.impl.RotatingTransition.java
License:Apache License
@Override public void render(Batch batch, Texture currentScreenTexture, Texture nextScreenTexture, float percent) { float width = currentScreenTexture.getWidth(); float height = currentScreenTexture.getHeight(); float x = 0;/* w ww .ja v a2s .c o m*/ float y = 0; float scalefactor; switch (scaling) { case IN: scalefactor = percent; break; case OUT: scalefactor = 1.0f - percent; break; case NONE: default: scalefactor = 1.0f; break; } float rotation = 1; if (interpolation != null) rotation = interpolation.apply(percent); batch.begin(); batch.draw(currentScreenTexture, 0, 0, width / 2, height / 2, width, height, 1, 1, 0, 0, 0, (int) width, (int) height, false, true); batch.draw(nextScreenTexture, 0, 0, width / 2, height / 2, nextScreenTexture.getWidth(), nextScreenTexture.getHeight(), scalefactor, scalefactor, rotation * angle, 0, 0, nextScreenTexture.getWidth(), nextScreenTexture.getHeight(), false, true); batch.end(); }
From source file:com.ixeption.libgdx.transitions.impl.SlicingTransition.java
License:Apache License
@Override public void render(Batch batch, Texture currentScreenTexture, Texture nextScreenTexture, float percent) { float width = currentScreenTexture.getWidth(); float height = currentScreenTexture.getHeight(); float x = 0;/*from ww w .j a v a 2 s . c o m*/ float y = 0; int sliceWidth = (int) (width / slices.size); batch.begin(); batch.draw(currentScreenTexture, 0, 0, 0, 0, width, height, 1, 1, 0, 0, 0, (int) width, (int) height, false, true); if (interpolation != null) percent = interpolation.apply(percent); for (int i = 0; i < slices.size; i++) { x = i * sliceWidth; float offsetY = height * (1 + slices.get(i) / (float) slices.size); switch (direction) { case UP: y = -offsetY + offsetY * percent; break; case DOWN: y = offsetY - offsetY * percent; break; case UPDOWN: if (i % 2 == 0) { y = -offsetY + offsetY * percent; } else { y = offsetY - offsetY * percent; } break; } batch.draw(nextScreenTexture, x, y, 0, 0, sliceWidth, nextScreenTexture.getHeight(), 1, 1, 0, i * sliceWidth, 0, sliceWidth, nextScreenTexture.getHeight(), false, true); } batch.end(); }
From source file:com.ixeption.libgdx.transitions.impl.SlidingTransition.java
License:Apache License
@Override public void render(Batch batch, Texture currentScreenTexture, Texture nextScreenTexture, float percent) { float width = currentScreenTexture.getWidth(); float height = currentScreenTexture.getHeight(); float x = 0;//w ww . j av a 2 s.c om float y = 0; if (interpolation != null) percent = interpolation.apply(percent); switch (direction) { case LEFT: x = -width * percent; if (!slideOut) x += width; break; case RIGHT: x = width * percent; if (!slideOut) x -= width; break; case UP: y = height * percent; if (!slideOut) y -= height; break; case DOWN: y = -height * percent; if (!slideOut) y += height; break; } Texture texBottom = slideOut ? nextScreenTexture : currentScreenTexture; Texture texTop = slideOut ? currentScreenTexture : nextScreenTexture; batch.begin(); batch.draw(texBottom, 0, 0, 0, 0, width, height, 1, 1, 0, 0, 0, (int) width, (int) height, false, true); batch.draw(texTop, x, y, 0, 0, nextScreenTexture.getWidth(), nextScreenTexture.getHeight(), 1, 1, 0, 0, 0, nextScreenTexture.getWidth(), nextScreenTexture.getHeight(), false, true); batch.end(); }
From source file:com.jmolina.orb.widgets.BaseActor.java
License:Open Source License
/** * Dibuja el actor/*from w ww . j av a2 s . c o m*/ * * @param batch Batch * @param parentAlpha Nivel alpha del padre */ @Override public void draw(Batch batch, float parentAlpha) { Color color = getColor(); batch.setColor(color.r, color.g, color.b, color.a * parentAlpha); // Metodo completo de dibujado batch.draw(region.getTexture(), this.getX(), this.getY(), this.getOriginX(), this.getOriginY(), this.getWidth(), this.getHeight(), this.getScaleX(), this.getScaleY(), this.getRotation(), region.getRegionX(), region.getRegionY(), region.getRegionWidth(), region.getRegionHeight(), false, false); // Evita que en algunos casos se modifique el color de la stage batch.setColor(color.r, color.g, color.b, color.a); }
From source file:es.eucm.ead.engine.assets.ScaledTexture.java
License:Open Source License
@Override public void draw(Batch batch, float x, float y, float width, float height) { int textureWidth = texture.getWidth(); int textureHeight = texture.getHeight(); batch.draw(texture, x, y, 0, 0, textureWidth, textureHeight, scale, scale, 0, 0, 0, textureWidth, textureHeight, false, false); }