Example usage for com.badlogic.gdx.graphics.g2d TextureRegion setRegionY

List of usage examples for com.badlogic.gdx.graphics.g2d TextureRegion setRegionY

Introduction

In this page you can find the example usage for com.badlogic.gdx.graphics.g2d TextureRegion setRegionY.

Prototype

public void setRegionY(int y) 

Source Link

Usage

From source file:com.agateau.pixelwheels.Assets.java

License:Open Source License

private static void removeBorders(TextureRegion region) {
    region.setRegionX(region.getRegionX() + 2);
    region.setRegionY(region.getRegionY() + 2);
    region.setRegionWidth(region.getRegionWidth() - 4);
    region.setRegionHeight(region.getRegionHeight() - 4);
}

From source file:com.idp.engine.net.NetworkImage.java

@Override
protected void sizeChanged() {
    if (texToDraw == null)
        return;/* ww w .  j  a  v  a 2  s .c  o m*/

    Texture tex = texToDraw.getTexture();
    if (tex == null)
        return;

    TextureRegion region = new TextureRegion(tex);

    float aspect = getWidth() / getHeight();
    float texAspect = tex.getWidth() * 1f / tex.getHeight();
    if (aspect > texAspect) {
        int h = (int) (tex.getHeight() * (texAspect / aspect));
        region.setRegionY((tex.getHeight() - h) / 2); // important to set pos before size
        region.setRegionWidth(tex.getWidth());
        region.setRegionHeight(h);
    } else {
        int w = (int) (tex.getWidth() / (texAspect / aspect));
        region.setRegionX((tex.getWidth() - w) / 2);
        region.setRegionHeight(tex.getHeight());
        region.setRegionWidth(w);
    }
    region.flip(false, true); // important to flip after all
    texToDraw = region;
}