use of com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasSprite in project commons-gdx by gemserk.
the class SpriteUtilsTest method shouldReturnAliasWhenAtlasRegionsAreEqual.
@Test
public void shouldReturnAliasWhenAtlasRegionsAreEqual() {
AtlasRegion atlasRegion1 = new AtlasRegion(texture512x512, 50, 30, 40, 40);
AtlasRegion atlasRegion2 = new AtlasRegion(texture512x512, 50, 30, 40, 40);
Sprite sprite1 = new AtlasSprite(atlasRegion1);
Sprite sprite2 = new AtlasSprite(atlasRegion2);
assertTrue(SpriteUtils.isAliasSprite(sprite1, sprite2));
}
use of com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasSprite in project commons-gdx by gemserk.
the class SpriteUtilsTest method shouldReturnNotAliasWhenAtlasRegionsAreNotEqual.
@Test
public void shouldReturnNotAliasWhenAtlasRegionsAreNotEqual() {
Sprite sprite1 = new AtlasSprite(new AtlasRegion(texture512x512, 50, 30, 40, 40));
Sprite sprite2 = new AtlasSprite(new AtlasRegion(texture512x512, 50, 30, 20, 40));
assertFalse(SpriteUtils.isAliasSprite(sprite1, sprite2));
}
use of com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasSprite in project gdx-skineditor by cobolfoo.
the class Skin method getSprite.
/**
* Returns a registered sprite. If no sprite is found but a region exists
* with the name, a sprite is created from the region and stored in the
* skin. If the region is an {@link AtlasRegion} then an {@link AtlasSprite}
* is used if the region has been whitespace stripped or packed rotated 90
* degrees.
*/
public Sprite getSprite(String name) {
Sprite sprite = optional(name, Sprite.class);
if (sprite != null)
return sprite;
try {
TextureRegion textureRegion = getRegion(name);
if (textureRegion instanceof AtlasRegion) {
AtlasRegion region = (AtlasRegion) textureRegion;
if (region.rotate || region.packedWidth != region.originalWidth || region.packedHeight != region.originalHeight)
sprite = new AtlasSprite(region);
}
if (sprite == null)
sprite = new Sprite(textureRegion);
add(name, sprite, NinePatch.class);
return sprite;
} catch (GdxRuntimeException ex) {
throw new GdxRuntimeException("No NinePatch, TextureRegion, or Texture registered with name: " + name);
}
}
use of com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasSprite 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));
}
use of com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasSprite in project commons-gdx by gemserk.
the class SpriteUtils method cloneSprite.
/**
* Returns a clone of a Sprite based on the type of the sprite.
*/
public static Sprite cloneSprite(Sprite sprite) {
if (sprite instanceof AtlasSprite) {
AtlasSprite atlasSprite = new AtlasSprite(((AtlasSprite) sprite).getAtlasRegion());
atlasSprite.set(sprite);
return atlasSprite;
} else {
return new Sprite(sprite);
}
}
Aggregations