use of com.badlogic.gdx.graphics.g2d.TextureRegion in project libgdx by libgdx.
the class TexturePanel method draw.
private void draw(Graphics g, Array<TextureRegion> regions, Color color, boolean drawIndex) {
int i = 0;
for (TextureRegion region : regions) {
int x = region.getRegionX(), y = region.getRegionY(), h = region.getRegionHeight();
if (drawIndex) {
String indexString = "" + i;
Rectangle bounds = g.getFontMetrics().getStringBounds(indexString, g).getBounds();
g.setColor(indexBackgroundColor);
g.fillRect(x, y + h - bounds.height, bounds.width, bounds.height);
g.setColor(indexColor);
g.drawString(indexString, x, y + h);
++i;
}
g.setColor(color);
g.drawRect(x, y, region.getRegionWidth(), h);
}
}
use of com.badlogic.gdx.graphics.g2d.TextureRegion in project libgdx by libgdx.
the class Skin method getRegion.
/** Returns a registered texture region. If no region is found but a texture exists with the name, a region is created from the
* texture and stored in the skin. */
public TextureRegion getRegion(String name) {
TextureRegion region = optional(name, TextureRegion.class);
if (region != null)
return region;
Texture texture = optional(name, Texture.class);
if (texture == null)
throw new GdxRuntimeException("No TextureRegion or Texture registered with name: " + name);
region = new TextureRegion(texture);
add(name, region, TextureRegion.class);
return region;
}
use of com.badlogic.gdx.graphics.g2d.TextureRegion in project libgdx by libgdx.
the class ActionSequenceTest method create.
@Override
public void create() {
stage = new Stage();
texture = new Texture(Gdx.files.internal("data/badlogic.jpg"), false);
texture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
img = new Image(new TextureRegion(texture));
img.setSize(100, 100);
img.setOrigin(50, 50);
img.setPosition(100, 100);
img2 = new Image(new TextureRegion(texture));
img2.setSize(100, 100);
img2.setOrigin(50, 50);
img2.setPosition(100, 100);
img3 = new Image(new TextureRegion(texture));
img3.setSize(100, 100);
img3.setOrigin(50, 50);
img3.setPosition(100, 100);
stage.addActor(img);
stage.addActor(img2);
stage.addActor(img3);
img.addAction(sequence());
img2.addAction(parallel(sequence(), moveBy(100, 0, 1)));
img3.addAction(sequence(parallel(moveBy(100, 200, 2)), Actions.run(this)));
}
use of com.badlogic.gdx.graphics.g2d.TextureRegion in project libgdx by libgdx.
the class BitmapFontDistanceFieldTest method create.
@Override
public void create() {
camera = new OrthographicCamera();
spriteBatch = new SpriteBatch();
descriptionFont = new BitmapFont(Gdx.files.internal("data/arial-15.fnt"), true);
descriptionFont.setColor(Color.RED);
regularTexture = new Texture(Gdx.files.internal("data/verdana39.png"), true);
regularFont = new BitmapFont(Gdx.files.internal("data/verdana39.fnt"), new TextureRegion(regularTexture), true);
regularFont.setColor(COLOR);
distanceFieldTexture = new Texture(Gdx.files.internal("data/verdana39distancefield.png"), true);
distanceFieldFont = new BitmapFont(Gdx.files.internal("data/verdana39distancefield.fnt"), new TextureRegion(distanceFieldTexture), true);
distanceFieldFont.setColor(COLOR);
distanceFieldShader = new DistanceFieldShader();
// Useful when debugging this test
ShaderProgram.pedantic = false;
}
use of com.badlogic.gdx.graphics.g2d.TextureRegion in project libgdx by libgdx.
the class ActionTest method create.
@Override
public void create() {
stage = new Stage();
texture = new Texture(Gdx.files.internal("data/badlogic.jpg"), false);
texture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
final Image img = new Image(new TextureRegion(texture));
img.setSize(100, 100);
img.setOrigin(50, 50);
img.setPosition(100, 100);
// img.addAction(forever(sequence(delay(1.0f), new Action() {
// public boolean act (float delta) {
// System.out.println(1);
// img.clearActions();
// return true;
// }
// })));
img.addAction(Actions.moveBy(100, 0, 2));
img.addAction(Actions.after(Actions.scaleTo(2, 2, 2)));
stage.addActor(img);
}
Aggregations