Java Code Examples for com.badlogic.gdx.graphics.g2d.SpriteBatch#draw()
The following examples show how to use
com.badlogic.gdx.graphics.g2d.SpriteBatch#draw() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GigaGal.java From ud406 with MIT License | 6 votes |
public void render(SpriteBatch batch) { TextureRegion region = Assets.instance.gigaGalAssets.standingRight; batch.draw( region.getTexture(), position.x - Constants.GIGAGAL_EYE_POSITION.x, position.y - Constants.GIGAGAL_EYE_POSITION.y, 0, 0, region.getRegionWidth(), region.getRegionHeight(), 1, 1, 0, region.getRegionX(), region.getRegionY(), region.getRegionWidth(), region.getRegionHeight(), false, false); }
Example 2
Source File: CraftingScreen.java From TerraLegion with MIT License | 6 votes |
@Override public void render(SpriteBatch sb) { sb.setProjectionMatrix(camera.combined); sb.begin(); sb.draw(bg, 0, 0); itemNameLabel.render(sb); itemInfoLabel.render(sb); cancelBtn.render(sb); craftingBtn.render(sb); invBtn.render(sb); if (selectedRecipe != null) craftBtn.render(sb); sb.end(); stage.draw(); }
Example 3
Source File: Utils.java From ud406 with MIT License | 6 votes |
public static void drawTextureRegion(SpriteBatch batch, TextureRegion region, float x, float y) { batch.draw( region.getTexture(), x, y, 0, 0, region.getRegionWidth(), region.getRegionHeight(), 1, 1, 0, region.getRegionX(), region.getRegionY(), region.getRegionWidth(), region.getRegionHeight(), false, false); }
Example 4
Source File: Utils.java From ud406 with MIT License | 6 votes |
public static void drawTextureRegion(SpriteBatch batch, TextureRegion region, float x, float y) { batch.draw( region.getTexture(), x, y, 0, 0, region.getRegionWidth(), region.getRegionHeight(), 1, 1, 0, region.getRegionX(), region.getRegionY(), region.getRegionWidth(), region.getRegionHeight(), false, false); }
Example 5
Source File: Utils.java From ud406 with MIT License | 6 votes |
public static void drawTextureRegion(SpriteBatch batch, TextureRegion region, float x, float y) { batch.draw( region.getTexture(), x, y, 0, 0, region.getRegionWidth(), region.getRegionHeight(), 1, 1, 0, region.getRegionX(), region.getRegionY(), region.getRegionWidth(), region.getRegionHeight(), false, false); }
Example 6
Source File: Animations.java From ud406 with MIT License | 6 votes |
private void drawRegionCentered(SpriteBatch batch, TextureRegion region, float x, float y) { batch.draw( region.getTexture(), x - region.getRegionWidth() / 2, y - region.getRegionHeight() / 2, 0, 0, region.getRegionWidth(), region.getRegionHeight(), 1, 1, 0, region.getRegionX(), region.getRegionY(), region.getRegionWidth(), region.getRegionHeight(), false, false); }
Example 7
Source File: RenderHealthBar.java From StSLib with MIT License | 6 votes |
private static void renderTempHPIconAndValue(AbstractCreature creature, SpriteBatch sb, float x, float y) { sb.setColor(Settings.GOLD_COLOR); sb.draw(StSLib.TEMP_HP_ICON, x + getPrivate(AbstractCreature.class, "BLOCK_ICON_X", Float.class) - 16.0f + creature.hb.width, y + getPrivate(AbstractCreature.class, "BLOCK_ICON_Y", Float.class) - 32.0f, 32.0f, 32.0f, 64.0f, 64.0f, Settings.scale, Settings.scale, 0.0f, 0, 0, 64, 64, false, false); FontHelper.renderFontCentered(sb, FontHelper.blockInfoFont, Integer.toString(TempHPField.tempHp.get(creature)), x + getPrivate(AbstractCreature.class, "BLOCK_ICON_X", Float.class) + 16.0f + creature.hb.width, y - 16.0f * Settings.scale, Settings.CREAM_COLOR, 1.0f); }
Example 8
Source File: Utils.java From ud406 with MIT License | 6 votes |
public static void drawTextureRegion(SpriteBatch batch, TextureRegion region, float x, float y) { batch.draw( region.getTexture(), x, y, 0, 0, region.getRegionWidth(), region.getRegionHeight(), 1, 1, 0, region.getRegionX(), region.getRegionY(), region.getRegionWidth(), region.getRegionHeight(), false, false); }
Example 9
Source File: Utils.java From ud406 with MIT License | 6 votes |
public static void drawTextureRegion(SpriteBatch batch, TextureRegion region, float x, float y) { batch.draw( region.getTexture(), x, y, 0, 0, region.getRegionWidth(), region.getRegionHeight(), 1, 1, 0, region.getRegionX(), region.getRegionY(), region.getRegionWidth(), region.getRegionHeight(), false, false); }
Example 10
Source File: Utils.java From ud406 with MIT License | 6 votes |
public static void drawTextureRegion(SpriteBatch batch, TextureRegion region, float x, float y) { batch.draw( region.getTexture(), x, y, 0, 0, region.getRegionWidth(), region.getRegionHeight(), 1, 1, 0, region.getRegionX(), region.getRegionY(), region.getRegionWidth(), region.getRegionHeight(), false, false); }
Example 11
Source File: ArcaneWeaponEffect.java From jorbs-spire-mod with MIT License | 5 votes |
@Override public void render(SpriteBatch sb) { sb.setBlendFunction(770, 1); sb.setColor(color); rotation = ((duration - startingDuration) * 180.0F) / startingDuration + 22.5F; sb.draw(img, targetX - MathUtils.sinDeg(rotation) * img.packedHeight / 2.0F, targetY + MathUtils.cosDeg(rotation) * img.packedHeight / 2.0F, 0.0F, (float) img.packedHeight / 2.0F, img.packedWidth, img.packedHeight, scale, scale, rotation); sb.setColor(1.0F, 0.3F, 0.25F, 0.7F); sb.draw(img, targetX - MathUtils.sinDeg(rotation) * img.packedHeight / 1.25F / 2.0F, targetY + MathUtils.cosDeg(rotation) * img.packedHeight / 1.25F / 2.0F, 0.0F, (float) img.packedHeight / 2.0F, img.packedWidth / 0.75F, img.packedHeight / 0.75F, scale, scale, rotation); }
Example 12
Source File: StatusSet.java From Unlucky with MIT License | 5 votes |
/** * Player's status bar renders from left to right * Enemy's renders from right to left * * @param batch */ public void render(SpriteBatch batch) { for (int i = 0; i < effects.size; i++) { StatusEffect s = effects.get(i); if (player) { if (s != null) batch.draw(s.icon, 1 + (i * 11), 90); } else { if (s != null) batch.draw(s.icon, 189 - (i * 11), 90); } } }
Example 13
Source File: SpriteBatchUtils.java From uracer-kotd with Apache License 2.0 | 5 votes |
public static void draw (SpriteBatch batch, TextureRegion region, float x, float y) { int width = region.getRegionWidth(); if (width < 0) { width = -width; } batch.draw(region, x, y, width, region.getRegionHeight()); }
Example 14
Source File: ScalingLaserEffect.java From jorbs-spire-mod with MIT License | 5 votes |
@Override public void render(SpriteBatch sb) { sb.setBlendFunction(770, 1); sb.setColor(this.color); sb.draw(img, this.sourceX, (this.sourceY - (float) img.packedHeight / 2.0F + 10.0F) - (Settings.scale * (beamThickness / 2)), 0.0F, (float) img.packedHeight / 2.0F, this.distance, 50.0F + (Settings.scale * beamThickness), this.scale + MathUtils.random(-0.01F, 0.01F), this.scale, this.rotation); sb.setColor(this.color2); sb.draw(img, this.sourceX, this.sourceY - (float) img.packedHeight / 2.0F - (Settings.scale * beamThickness / 4), 0.0F, (float) img.packedHeight / 2.0F, this.distance, MathUtils.random(50.0F, 90.0F) + (Settings.scale * beamThickness / 2), this.scale + MathUtils.random(-0.02F, 0.02F), this.scale, this.rotation); sb.setBlendFunction(770, 771); }
Example 15
Source File: ScrollingBackground.java From libgdx-2d-tutorial with MIT License | 5 votes |
public void updateAndRender (float deltaTime, SpriteBatch batch) { //Speed adjustment to reach goal if (speed < goalSpeed) { speed += GOAL_REACH_ACCELERATION * deltaTime; if (speed > goalSpeed) speed = goalSpeed; } else if (speed > goalSpeed) { speed -= GOAL_REACH_ACCELERATION * deltaTime; if (speed < goalSpeed) speed = goalSpeed; } if (!speedFixed) speed += ACCELERATION * deltaTime; y1 -= speed * deltaTime; y2 -= speed * deltaTime; //if image reached the bottom of screen and is not visible, put it back on top if (y1 + image.getHeight() * imageScale <= 0) y1 = y2 + image.getHeight() * imageScale; if (y2 + image.getHeight() * imageScale <= 0) y2 = y1 + image.getHeight() * imageScale; //Render batch.draw(image, 0, y1, SpaceGame.WIDTH, image.getHeight() * imageScale); batch.draw(image, 0, y2, SpaceGame.WIDTH, image.getHeight() * imageScale); }
Example 16
Source File: HelpScreen.java From bladecoder-adventure-engine with Apache License 2.0 | 5 votes |
@Override public void render(float delta) { SpriteBatch batch = ui.getBatch(); Gdx.gl.glClearColor(0, 0, 0, 1); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); batch.setProjectionMatrix(viewport.getCamera().combined); batch.begin(); batch.draw(tex, 0, 0, viewport.getScreenWidth(), viewport.getScreenHeight()); batch.end(); }
Example 17
Source File: BasicInfo.java From uracer-kotd with Apache License 2.0 | 4 votes |
public void render (SpriteBatch batch) { batch.draw(flagRegion, borderX, borderY, w, h); name.render(batch); }
Example 18
Source File: HealthBarRenderPowerPatch.java From StSLib with MIT License | 4 votes |
@SpireInsertPatch( locator=Locator.class, localvars={"x", "y", "targetHealthBarWidth", "HEALTH_BAR_HEIGHT", "HEALTH_BAR_OFFSET_Y"} ) public static void Insert(AbstractCreature __instance, SpriteBatch sb, float x, float y, float targetHealthBarWidth, float HEALTH_BAR_HEIGHT, float HEALTH_BAR_OFFSET_Y) { int poisonAmt = 0; if (__instance.hasPower(PoisonPower.POWER_ID)) { poisonAmt = __instance.getPower(PoisonPower.POWER_ID).amount; if (poisonAmt > 0 && __instance.hasPower(IntangiblePower.POWER_ID)) { poisonAmt = 1; } } int prevPowerAmtSum = poisonAmt; for (AbstractPower power : __instance.powers) { if (power instanceof HealthBarRenderPower) { sb.setColor(((HealthBarRenderPower) power).getColor()); int amt = ((HealthBarRenderPower) power).getHealthBarAmount(); if (amt > 0 && __instance.hasPower(IntangiblePower.POWER_ID)) { amt = 1; } if (__instance.currentHealth > prevPowerAmtSum) { float w = 1.0f - (__instance.currentHealth - prevPowerAmtSum) / (float) __instance.currentHealth; w *= targetHealthBarWidth; if (__instance.currentHealth > 0) { sb.draw(ImageMaster.HEALTH_BAR_L, x - HEALTH_BAR_HEIGHT, y + HEALTH_BAR_OFFSET_Y, HEALTH_BAR_HEIGHT, HEALTH_BAR_HEIGHT); } sb.draw(ImageMaster.HEALTH_BAR_B, x, y + HEALTH_BAR_OFFSET_Y, targetHealthBarWidth - w, HEALTH_BAR_HEIGHT); sb.draw(ImageMaster.HEALTH_BAR_R, x + targetHealthBarWidth - w, y + HEALTH_BAR_OFFSET_Y, HEALTH_BAR_HEIGHT, HEALTH_BAR_HEIGHT); } prevPowerAmtSum += amt; } } allAmtSum = prevPowerAmtSum; prevPowerAmtSum -= poisonAmt; nonPoisonWidthSum = 1.0f - (__instance.currentHealth - prevPowerAmtSum) / (float) __instance.currentHealth; nonPoisonWidthSum *= targetHealthBarWidth; }
Example 19
Source File: AnalogueClock.java From FruitCatcher with Apache License 2.0 | 4 votes |
public void draw(SpriteBatch batch, int x, int y) { batch.draw(base, x, y); float width = 0; float height = 0; float rotation = 0; float scaleX = 1f; float scaleY = 1f; float originX = 0; float originY = 0; float posX = x + (base.getRegionWidth()/2); float posY = y +(base.getRegionHeight()/2); if (seconds > 30) { } else if (seconds > 15) { width = secondImages[14].getRegionWidth(); height = secondImages[14].getRegionHeight(); batch.draw(secondImages[14], posX+1, posY+1, originX, originY, width, height, scaleX, scaleY, rotation); rotation = 270; width = secondImages[seconds-16].getRegionWidth(); height = secondImages[seconds-16].getRegionHeight(); batch.draw(secondImages[seconds-16], posX+1, posY+1, originX, originY, width, height, scaleX, scaleY, rotation); } else if (seconds > 5){ width = secondImages[seconds-1].getRegionWidth(); height = secondImages[seconds-1].getRegionHeight(); batch.draw(secondImages[seconds-1], posX+1, posY+1, originX, originY, width, height, scaleX, scaleY, rotation); } else if (seconds > 0){ width = secondRedImages[seconds-1].getRegionWidth(); height = secondRedImages[seconds-1].getRegionHeight(); batch.draw(secondRedImages[seconds-1], posX+1, posY+1, originX, originY, width, height, scaleX, scaleY, rotation); } }
Example 20
Source File: FringeLayer.java From RuinsOfRevenge with MIT License | 4 votes |
public void end(SpriteBatch batch) { for (int i = currentInd; i < tiles.size(); i++) { FringeTile tile = tiles.get(i); batch.draw(tile.cell.getTile().getTextureRegion(), tile.x, tile.y, 1f, 1f); } }