Java Code Examples for com.badlogic.gdx.graphics.g2d.SpriteBatch#getTransformMatrix()
The following examples show how to use
com.badlogic.gdx.graphics.g2d.SpriteBatch#getTransformMatrix() .
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: ParticleRenderer.java From bladecoder-adventure-engine with Apache License 2.0 | 5 votes |
@Override public void draw(SpriteBatch batch, float x, float y, float scaleX, float scaleY, float rotation, Color tint) { float finalScaleX = EngineAssetManager.getInstance().getScale() * scaleX; float finalScaleY = EngineAssetManager.getInstance().getScale() * scaleY; if (effect.getEmitters().size > 0) { Matrix4 tm = batch.getTransformMatrix(); tmp.set(tm); if (tmpPosX != x / finalScaleX || tmpPosY != y / finalScaleY) { tmpPosX = x / finalScaleX; tmpPosY = y / finalScaleY; effect.setPosition(tmpPosX, tmpPosY); } tm.rotate(0, 0, 1, rotation).scale(finalScaleX, finalScaleY, 1); batch.setTransformMatrix(tm); if (tint != null) batch.setColor(tint); effect.draw(batch); if (tint != null) batch.setColor(Color.WHITE); batch.setTransformMatrix(tmp); } else { x = x - getWidth() / 2 * finalScaleX; RectangleRenderer.draw(batch, x, y, getWidth() * finalScaleX, getHeight() * finalScaleY, Color.RED); } }
Example 2
Source File: SpineRenderer.java From bladecoder-adventure-engine with Apache License 2.0 | 5 votes |
@Override public void draw(SpriteBatch batch, float x, float y, float scaleX, float scaleY, float rotation, Color tint) { SkeletonCacheEntry cs = (SkeletonCacheEntry) currentSource; if (cs != null && cs.skeleton != null) { Matrix4 tm = batch.getTransformMatrix(); tmp.set(tm); float originX = cs.skeleton.getRootBone().getX(); float originY = cs.skeleton.getRootBone().getY(); tm.translate(x, y, 0).rotate(0, 0, 1, rotation).scale(scaleX, scaleY, 1).translate(originX, originY, 0); // cs.skeleton.setX(x / scale); // cs.skeleton.setY(y / scale); batch.setTransformMatrix(tm); if (tint != null) cs.skeleton.setColor(tint); renderer.draw(batch, cs.skeleton); if (tint != null) batch.setColor(Color.WHITE); batch.setTransformMatrix(tmp); } else { float dx = getAlignDx(getWidth(), orgAlign); float dy = getAlignDy(getHeight(), orgAlign); RectangleRenderer.draw(batch, x + dx * scaleX, y + dy * scaleY, getWidth() * scaleX, getHeight() * scaleY, Color.RED); } }
Example 3
Source File: DebugCarEngineVolumes.java From uracer-kotd with Apache License 2.0 | 4 votes |
@Override public void renderBatch (SpriteBatch batch) { if (isActive() && meters.size > 0) { Matrix4 prev = batch.getTransformMatrix(); batch.setTransformMatrix(idt); batch.enableBlending(); float prevHeight = 0; int index = 0; int drawx = 410; int drawy = 0; SpriteBatchUtils.drawString(batch, "car engine soundset", drawx, drawy); SpriteBatchUtils.drawString(batch, "=======================", drawx, drawy + Art.DebugFontHeight); String text; for (DebugMeter m : meters) { int x = drawx, y = drawy + Art.DebugFontHeight * 2; // offset by index y += index * (prevHeight + 1); // compute color float alpha = 1; Color c = ColorUtils.paletteRYG(1.5f - m.getValue() * 1.5f, alpha); { // render track number text = sampleNames[index]; batch.setColor(1, 1, 1, alpha); SpriteBatchUtils.drawString(batch, text, x, y); batch.setColor(1, 1, 1, 1); // render meter after text int meter_x = x + (text.length() * Art.DebugFontWidth) + 2; m.color.set(c); m.setPosition(meter_x, y); m.render(batch); // render volume numerical value text = String.format("%.02f", m.getValue()); batch.setColor(1, 1, 1, alpha); SpriteBatchUtils.drawString(batch, text, meter_x + m.getWidth() + 2, y); batch.setColor(1, 1, 1, 1); } index++; prevHeight = m.getHeight(); } batch.setTransformMatrix(prev); batch.disableBlending(); } }
Example 4
Source File: DebugMusicVolumes.java From uracer-kotd with Apache License 2.0 | 4 votes |
@Override public void renderBatch (SpriteBatch batch) { if (isActive() && meters.size > 0) { Matrix4 prev = batch.getTransformMatrix(); batch.setTransformMatrix(idt); batch.enableBlending(); float prevHeight = 0; int index = 0; int drawx = 275; int drawy = 0; int maxMusicIndex = tensiveMusic.getCurrentMusicIndexLimit(); SpriteBatchUtils.drawString(batch, "music tracks max=" + maxMusicIndex, drawx, drawy); SpriteBatchUtils.drawString(batch, "==================", drawx, drawy + Art.DebugFontHeight); String text; for (DebugMeter m : meters) { int x = drawx, y = drawy + Art.DebugFontHeight * 2; // offset by index y += index * (prevHeight + 1); // compute color float alpha = index > maxMusicIndex ? 0.5f : 1; Color c = ColorUtils.paletteRYG(1.5f - m.getValue() * 1.5f, alpha); { // render track number text = "T" + (index + 1); batch.setColor(1, 1, 1, alpha); SpriteBatchUtils.drawString(batch, text, x, y); batch.setColor(1, 1, 1, 1); // render meter after text int meter_x = x + (text.length() * Art.DebugFontWidth) + 2; m.color.set(c); m.setPosition(meter_x, y); m.render(batch); // render volume numerical value text = String.format("%.02f", m.getValue()); batch.setColor(1, 1, 1, alpha); SpriteBatchUtils.drawString(batch, text, meter_x + m.getWidth() + 2, y); batch.setColor(1, 1, 1, 1); } index++; prevHeight = m.getHeight(); } SpriteBatchUtils.drawString(batch, "total volume = " + String.format("%.02f", totalVolume), drawx, Art.DebugFontHeight * (meters.size + 3)); batch.setTransformMatrix(prev); batch.disableBlending(); } }
Example 5
Source File: TextRenderer.java From bladecoder-adventure-engine with Apache License 2.0 | 4 votes |
@Override public void draw(SpriteBatch batch, float x, float y, float scaleX, float scaleY, float rotation, Color tint) { float dx = getAlignDx(getWidth(), orgAlign); float dy = getAlignDy(getHeight(), orgAlign); if (font != null && text != null) { if (tint != null && !tint.equals(color)) { color.set(tint); String tt = text; if (tt.charAt(0) == I18N.PREFIX) tt = world.getI18N().getString(tt.substring(1)); if (editorTranslatedText != null) tt = editorTranslatedText; layout.setText(font, tt, color, 0, textAlign, false); } Matrix4 tm = batch.getTransformMatrix(); tmp.set(tm); float originX = dx; float originY = layout.height + dy; if (textAlign == Align.right) originX += getWidth(); else if (textAlign == Align.center) originX += getWidth() / 2; tm.translate(x, y, 0).rotate(0, 0, 1, rotation).scale(scaleX, scaleY, 1).translate(originX, originY, 0); batch.setTransformMatrix(tm); font.draw(batch, layout, 0, 0); batch.setTransformMatrix(tmp); } else { RectangleRenderer.draw(batch, x + dx * scaleX, y + dy * scaleY, getWidth() * scaleX, getHeight() * scaleY, Color.RED); } }