Search in sources :

Example 61 with TextureRegion

use of com.badlogic.gdx.graphics.g2d.TextureRegion in project commons-gdx by gemserk.

the class SpriteUtils method cut.

/**
	 * Modifies the Sprite region to the given TextureRegion by the SpriteRegion and its internal inner region relative values.
	 * 
	 * @param sprite
	 *            The Sprite to be modified.
	 * @param spriteRegion
	 *            The SpriteRegion with the values to be used when cutting the Sprite.
	 */
public static void cut(Sprite sprite, SpriteRegion spriteRegion) {
    TextureRegion textureRegion = spriteRegion.textureRegion;
    float u0 = spriteRegion.u0;
    float v0 = spriteRegion.v0;
    float u1 = spriteRegion.u1;
    float v1 = spriteRegion.v1;
    float width = spriteRegion.width;
    float height = spriteRegion.height;
    cut(sprite, textureRegion, u0, v0, u1, v1, width, height);
}
Also used : TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion)

Example 62 with TextureRegion

use of com.badlogic.gdx.graphics.g2d.TextureRegion in project commons-gdx by gemserk.

the class SpriteUtilsTest method shouldReturnIsAliasWhenSameRegion.

@Test
public void shouldReturnIsAliasWhenSameRegion() {
    TextureRegion region1 = new TextureRegion(texture512x512, 50, 30, 40f, 40f);
    Sprite sprite1 = new Sprite(region1);
    Sprite sprite2 = new Sprite(region1);
    assertTrue(SpriteUtils.isAliasSprite(sprite1, sprite2));
}
Also used : TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) AtlasSprite(com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasSprite) Sprite(com.badlogic.gdx.graphics.g2d.Sprite) Test(org.junit.Test)

Example 63 with TextureRegion

use of com.badlogic.gdx.graphics.g2d.TextureRegion in project commons-gdx by gemserk.

the class SpriteUtilsTest method shouldReturnIsAliasWhenSameSprite.

@Test
public void shouldReturnIsAliasWhenSameSprite() {
    TextureRegion region1 = new TextureRegion(texture512x512, 50, 30, 40f, 40f);
    Sprite sprite1 = new Sprite(region1);
    assertTrue(SpriteUtils.isAliasSprite(sprite1, sprite1));
}
Also used : TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) AtlasSprite(com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasSprite) Sprite(com.badlogic.gdx.graphics.g2d.Sprite) Test(org.junit.Test)

Example 64 with TextureRegion

use of com.badlogic.gdx.graphics.g2d.TextureRegion in project commons-gdx by gemserk.

the class SpriteUtilsTest method shouldReturnNotAliasWhenSpriteAndAtlasSprite.

@Test
public void shouldReturnNotAliasWhenSpriteAndAtlasSprite() {
    TextureRegion region1 = new TextureRegion(texture512x512, 50, 30, 40f, 40f);
    Sprite sprite1 = new Sprite(region1);
    Sprite sprite2 = new AtlasSprite(new AtlasRegion(texture512x512, 50, 30, 40, 40));
    assertFalse(SpriteUtils.isAliasSprite(sprite1, sprite2));
}
Also used : TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) AtlasSprite(com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasSprite) Sprite(com.badlogic.gdx.graphics.g2d.Sprite) AtlasSprite(com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasSprite) AtlasRegion(com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion) Test(org.junit.Test)

Example 65 with TextureRegion

use of com.badlogic.gdx.graphics.g2d.TextureRegion in project commons-gdx by gemserk.

the class SpriteUtilsTest method shouldReturnNotAliasWhenRegionAreNotEqual.

@Test
public void shouldReturnNotAliasWhenRegionAreNotEqual() {
    TextureRegion region1 = new TextureRegion(texture512x512, 50, 30, 40f, 40f);
    TextureRegion region2 = new TextureRegion(texture512x512, 50, 30, 10f, 40f);
    Sprite sprite1 = new Sprite(region1);
    Sprite sprite2 = new Sprite(region2);
    assertFalse(SpriteUtils.isAliasSprite(sprite1, sprite2));
}
Also used : TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) AtlasSprite(com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasSprite) Sprite(com.badlogic.gdx.graphics.g2d.Sprite) Test(org.junit.Test)

Aggregations

TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)115 Texture (com.badlogic.gdx.graphics.Texture)57 SpriteBatch (com.badlogic.gdx.graphics.g2d.SpriteBatch)22 BitmapFont (com.badlogic.gdx.graphics.g2d.BitmapFont)18 Stage (com.badlogic.gdx.scenes.scene2d.Stage)18 Sprite (com.badlogic.gdx.graphics.g2d.Sprite)13 GdxRuntimeException (com.badlogic.gdx.utils.GdxRuntimeException)13 OrthographicCamera (com.badlogic.gdx.graphics.OrthographicCamera)11 NinePatch (com.badlogic.gdx.graphics.g2d.NinePatch)11 AtlasSprite (com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasSprite)11 AtlasRegion (com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion)10 Image (com.badlogic.gdx.scenes.scene2d.ui.Image)10 Skin (com.badlogic.gdx.scenes.scene2d.ui.Skin)10 Pixmap (com.badlogic.gdx.graphics.Pixmap)8 Color (com.badlogic.gdx.graphics.Color)7 ShapeRenderer (com.badlogic.gdx.graphics.glutils.ShapeRenderer)7 TextureRegionDrawable (com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable)7 Test (org.junit.Test)7 FileHandle (com.badlogic.gdx.files.FileHandle)6 TextureAtlas (com.badlogic.gdx.graphics.g2d.TextureAtlas)6