List of usage examples for com.badlogic.gdx.graphics.g2d SpriteBatch getColor
@Override
public Color getColor()
From source file:com.minekrash.game.Paint.java
public void drawImageAlpha(SpriteBatch g, Texture _image, float _x, float _y, float _size, float _alpha) { g.setColor(g.getColor().r, g.getColor().g, g.getColor().b, _alpha); g.draw(_image, _x - ((_image.getWidth() / 2) * ESCALA_METROS), _y, (_image.getWidth() * ESCALA_METROS) + _size, (_image.getHeight() * ESCALA_METROS) + _size); g.setColor(g.getColor().r, g.getColor().g, g.getColor().b, 1f); }
From source file:com.minekrash.game.Paint.java
public void drawImageFlip(SpriteBatch g, Texture _image, float _x, float _y, boolean _flipHorizontal, boolean _pressing) { if (!_pressing) { g.setColor(g.getColor().r, g.getColor().g, g.getColor().b, 0.3f); } else {//from w w w . j av a 2s. c o m g.setColor(g.getColor().r, g.getColor().g, g.getColor().b, 1f); } if (_flipHorizontal) { g.draw(_image, _x * ESCALA_METROS, _y * ESCALA_METROS, -_image.getWidth() * ESCALA_METROS, _image.getHeight() * ESCALA_METROS); } else { g.draw(_image, _x * ESCALA_METROS, _y * ESCALA_METROS, _image.getWidth() * ESCALA_METROS, _image.getHeight() * ESCALA_METROS); } g.setColor(g.getColor().r, g.getColor().g, g.getColor().b, 1f); }
From source file:com.minekrash.game.Paint.java
public void drawBackground(SpriteBatch g, Texture _image, float _alpha) { g.setColor(g.getColor().r, g.getColor().g, g.getColor().b, _alpha); g.draw(_image, -(_image.getWidth() / 2) * ESCALA_METROS, -(_image.getHeight() / 2) * ESCALA_METROS, _image.getWidth() * ESCALA_METROS, _image.getHeight() * ESCALA_METROS); }
From source file:com.ridiculousRPG.animation.WeatherEffectLayer.java
License:Apache License
/** * Draw the effect-layer./*from w ww.j ava2s .c o m*/ */ public void draw(SpriteBatch batch, Camera cam, boolean debug) { if (flip) { batch.setTransformMatrix(compTransMatrix(batch, cam)); } if (fadeAlpha < 1f) { Color c = batch.getColor(); c.a *= fadeAlpha; batch.setColor(c); fadeAlpha += fadeBy * Gdx.graphics.getDeltaTime(); if (fadeAlpha > 1f) fadeAlpha = 1f; } // load frequently used variables into registers Texture t = tRef.getTexture(); int tWidth = tRef.getRegionWidth(); int tHeight = tRef.getRegionHeight(); float x1 = Math.max(0f, cam.position.x); float y1 = Math.max(0f, cam.position.y); float x2 = Math.min(width, x1 + cam.viewportWidth); float y2 = Math.min(height, y1 + cam.viewportHeight); float x3 = x1 - tWidth; float y3 = y1 - tHeight; float x4 = x2 - tWidth; float y4 = y2 - tHeight; for (List<Rectangle> row : tileLayer) { for (Rectangle clip : row) { float x = clip.x; float y = clip.y; if (x > x3 && y > y3 && x < x2 && y < y2) { // texel space origin is upper left corner (unlike screen // space) int srcX = 0; int srcY = 0; int srcWidth = tWidth; int srcHeight = tHeight; if (x < x1) { srcX = (int) (x1 - x + .7f); srcWidth -= srcX; x += srcX; } if (x > x4) { srcWidth -= x - x4; } if (y < y1) { srcHeight -= y1 - y; y = y1; } if (y > y4) { srcY = (int) (y - y4); srcHeight -= srcY; y += y - y4 - srcY; } batch.draw(t, x, y, srcX, srcY, srcWidth, srcHeight); } } } if (flip) { batch.setTransformMatrix(batch.getTransformMatrix().idt()); } /* * if (debug) { batch.end(); List<Rectangle> rects = new * ArrayList<Rectangle>(); for (List<Rectangle> row : tileLayer) for * (Rectangle clip : row) rects.add(new Rectangle(clip.x, clip.y, * Math.abs(tWidth), Math.abs(tHeight))); DebugHelper.debugRectangle(new * Color(1f, 0.67f, 0f, .4f), flip ? compTransMatrix(batch, cam) : null, * rects .toArray(new Rectangle[0])); batch.begin(); } */ }
From source file:game.objects.Bullet.java
@Override public void draw(SpriteBatch batch) { Color c = batch.getColor(); if (red)/*from ww w. ja v a 2 s .com*/ batch.setColor(Color.RED); super.draw(batch); if (red) batch.setColor(c); }
From source file:kyle.game.besiege.army.Army.java
License:Open Source License
public void drawCrest(SpriteBatch batch) { float size_factor = .4f; size_factor += .005 * this.party.getTotalSize(); Color temp = batch.getColor(); float zoom = getKingdom().getMapScreen().getCamera().zoom; zoom *= size_factor;/*from w ww .j a v a2 s . c om*/ Color clear_white = new Color(); clear_white.b = 1; clear_white.r = 1; clear_white.g = 1; clear_white.a = .6f; batch.setColor(clear_white); batch.draw(this.getFaction().crest, getCenterX() - 14 * zoom, getCenterY() + 5 + 5 * zoom, 30 * zoom, 45 * zoom); batch.setColor(temp); }
From source file:kyle.game.besiege.location.Location.java
License:Open Source License
public void drawCrest(SpriteBatch batch) { float size_factor = 1.4f; if ((this.type == LocationType.VILLAGE)) size_factor = .5f * size_factor; if ((this.type == LocationType.CASTLE)) size_factor = .7f * size_factor; Color temp = batch.getColor(); float zoom = getKingdom().getMapScreen().getCamera().zoom; zoom *= size_factor;/*from w w w . j a va 2s. c o m*/ // TODO do some vector calculations to make this rotate // TODO create a bunch more fonts for smoother scrolling! // TODO do this in Kingdom at the end of everything // don't draw village names at a certain point. if (!(this.type == LocationType.VILLAGE && zoom > 1.5) && !(this.type == LocationType.CASTLE && zoom > 3)) { BitmapFont font; if (zoom > 7) { font = Assets.pixel150; zoom = 7; } else if (zoom > 5) { font = Assets.pixel100; zoom = 5; } else if (zoom > 4) { font = Assets.pixel80; zoom = 4; } else if (zoom > 3) { font = Assets.pixel64; zoom = 3; } // add some fonts here for smoothness else if (zoom > 2.5) { font = Assets.pixel50; zoom = 2.5f; } else if (zoom > 2) { font = Assets.pixel40; zoom = 2f; } else if (zoom > 1.5) { font = Assets.pixel30; zoom = 1.5f; } else if (zoom > 1.2) { font = Assets.pixel24; zoom = 1.2f; } else if (zoom > 1) { font = Assets.pixel20; zoom = 1f; } else if (zoom > .75) { font = Assets.pixel15; zoom = .75f; } else { font = Assets.pixel12; zoom = .6f; } // draw crest Color clear_white = new Color(); clear_white.b = 1; clear_white.r = 1; clear_white.g = 1; clear_white.a = .6f; batch.setColor(clear_white); batch.draw(this.getFaction().crest, getCenterX() - 14 * zoom, getCenterY() + 5 + 5 * zoom, 30 * zoom, 45 * zoom); batch.setColor(temp); // // draw text // font.setColor(clear_white); // String toDraw = getName(); // font.draw(batch, toDraw, getX() - (int) (4.3*toDraw.length())*zoom, getY()-5-5*zoom); } }
From source file:kyle.game.besiege.location.Location.java
License:Open Source License
public void drawText(SpriteBatch batch) { float size_factor = 1.4f; if ((this.type == LocationType.VILLAGE)) size_factor = .5f * size_factor; if ((this.type == LocationType.CASTLE)) size_factor = .7f * size_factor; Color temp = batch.getColor(); float zoom = getKingdom().getMapScreen().getCamera().zoom; zoom *= size_factor;/* w w w. j a v a2s . co m*/ // TODO do some vector calculations to make this rotate // TODO create a bunch more fonts for smoother scrolling! // TODO do this in Kingdom at the end of everything // don't draw village names at a certain point. if (!(this.type == LocationType.VILLAGE && zoom > 1.5) && !(this.type == LocationType.CASTLE && zoom > 3)) { BitmapFont font; if (zoom > 7) { font = Assets.pixel150; zoom = 7; } else if (zoom > 5) { font = Assets.pixel100; zoom = 5; } else if (zoom > 4) { font = Assets.pixel80; zoom = 4; } else if (zoom > 3) { font = Assets.pixel64; zoom = 3; } // add some fonts here for smoothness else if (zoom > 2.5) { font = Assets.pixel50; zoom = 2.5f; } else if (zoom > 2) { font = Assets.pixel40; zoom = 2f; } else if (zoom > 1.5) { font = Assets.pixel30; zoom = 1.5f; } else if (zoom > 1.2) { font = Assets.pixel24; zoom = 1.2f; } else if (zoom > 1) { font = Assets.pixel20; zoom = 1f; } else if (zoom > .75) { font = Assets.pixel15; zoom = .75f; } else { font = Assets.pixel12; zoom = .6f; } String toDraw = getName(); Matrix4 mx4Font = new Matrix4(); mx4Font.trn((getX() - (int) (4.3 * toDraw.length()) * zoom), (getY() - 5 - 5 * zoom), 0); mx4Font.setToRotation(new Vector3(0, 0, 1), getKingdom().getMapScreen().getRotation()); Matrix4 tempMatrix = batch.getTransformMatrix(); batch.setTransformMatrix(mx4Font); // // draw crest Color clear_white = new Color(); clear_white.b = 1; clear_white.r = 1; clear_white.g = 1; clear_white.a = .8f; // batch.setColor(clear_white); // batch.draw(this.getFaction().crest, getCenterX() - 14*zoom, getCenterY() + 13, 30*zoom, 45*zoom); // batch.setColor(temp); // draw text font.setColor(clear_white); font.draw(batch, toDraw, getX() - (int) (4.3 * toDraw.length()) * zoom, getY() - 5 - 5 * zoom); batch.setTransformMatrix(tempMatrix); } }
From source file:org.bladecoder.bladeengine.util.RectangleRenderer.java
License:Apache License
public static void draw(SpriteBatch batch, float posX, float posY, float width, float height, Color color) { if (texture == null) texture = makePixel();/*from ww w. ja va2 s . co 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); }