/** 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, Sprite.class); return sprite; } catch (GdxRuntimeException ex) { throw new GdxRuntimeException("No NinePatch, TextureRegion, or Texture registered with name: " + name); } }
/** Creates a new drawable that renders the same as this drawable tinted the specified color. */ public Drawable tint (Color tint) { Sprite sprite; if (region instanceof AtlasRegion) sprite = new AtlasSprite((AtlasRegion)region); else sprite = new Sprite(region); sprite.setColor(tint); sprite.setSize(getMinWidth(), getMinHeight()); SpriteDrawable drawable = new SpriteDrawable(sprite); drawable.setLeftWidth(getLeftWidth()); drawable.setRightWidth(getRightWidth()); drawable.setTopHeight(getTopHeight()); drawable.setBottomHeight(getBottomHeight()); return drawable; } }
/** Creates a new drawable that renders the same as this drawable tinted the specified color. */ public SpriteDrawable tint (Color tint) { Sprite newSprite; if (sprite instanceof AtlasSprite) newSprite = new AtlasSprite((AtlasSprite)sprite); else newSprite = new Sprite(sprite); newSprite.setColor(tint); newSprite.setSize(getMinWidth(), getMinHeight()); SpriteDrawable drawable = new SpriteDrawable(newSprite); drawable.setLeftWidth(getLeftWidth()); drawable.setRightWidth(getRightWidth()); drawable.setTopHeight(getTopHeight()); drawable.setBottomHeight(getBottomHeight()); return drawable; } }
private Sprite newSprite (AtlasRegion region) { if (region.packedWidth == region.originalWidth && region.packedHeight == region.originalHeight) { if (region.rotate) { Sprite sprite = new Sprite(region); sprite.setBounds(0, 0, region.getRegionHeight(), region.getRegionWidth()); sprite.rotate90(true); return sprite; } return new Sprite(region); } return new AtlasSprite(region); }
/** 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, Sprite.class); return sprite; } catch (GdxRuntimeException ex) { throw new GdxRuntimeException("No NinePatch, TextureRegion, or Texture registered with name: " + name); } }
/** 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, Sprite.class); return sprite; } catch (GdxRuntimeException ex) { throw new GdxRuntimeException("No NinePatch, TextureRegion, or Texture registered with name: " + name); } }
/** Creates a new drawable that renders the same as this drawable tinted the specified color. */ public SpriteDrawable tint (Color tint) { Sprite newSprite; if (sprite instanceof AtlasSprite) newSprite = new AtlasSprite((AtlasSprite)sprite); else newSprite = new Sprite(sprite); newSprite.setColor(tint); newSprite.setSize(getMinWidth(), getMinHeight()); SpriteDrawable drawable = new SpriteDrawable(newSprite); drawable.setLeftWidth(getLeftWidth()); drawable.setRightWidth(getRightWidth()); drawable.setTopHeight(getTopHeight()); drawable.setBottomHeight(getBottomHeight()); return drawable; } }
/** Creates a new drawable that renders the same as this drawable tinted the specified color. */ public SpriteDrawable tint (Color tint) { Sprite newSprite; if (sprite instanceof AtlasSprite) newSprite = new AtlasSprite((AtlasSprite)sprite); else newSprite = new Sprite(sprite); newSprite.setColor(tint); newSprite.setSize(getMinWidth(), getMinHeight()); SpriteDrawable drawable = new SpriteDrawable(newSprite); drawable.setLeftWidth(getLeftWidth()); drawable.setRightWidth(getRightWidth()); drawable.setTopHeight(getTopHeight()); drawable.setBottomHeight(getBottomHeight()); return drawable; } }
/** Creates a new drawable that renders the same as this drawable tinted the specified color. */ public Drawable tint (Color tint) { Sprite sprite; if (region instanceof AtlasRegion) sprite = new AtlasSprite((AtlasRegion)region); else sprite = new Sprite(region); sprite.setColor(tint); sprite.setSize(getMinWidth(), getMinHeight()); SpriteDrawable drawable = new SpriteDrawable(sprite); drawable.setLeftWidth(getLeftWidth()); drawable.setRightWidth(getRightWidth()); drawable.setTopHeight(getTopHeight()); drawable.setBottomHeight(getBottomHeight()); return drawable; } }
/** Creates a new drawable that renders the same as this drawable tinted the specified color. */ public Drawable tint (Color tint) { Sprite sprite; if (region instanceof AtlasRegion) sprite = new AtlasSprite((AtlasRegion)region); else sprite = new Sprite(region); sprite.setColor(tint); sprite.setSize(getMinWidth(), getMinHeight()); SpriteDrawable drawable = new SpriteDrawable(sprite); drawable.setLeftWidth(getLeftWidth()); drawable.setRightWidth(getRightWidth()); drawable.setTopHeight(getTopHeight()); drawable.setBottomHeight(getBottomHeight()); return drawable; } }
private Sprite newSprite (AtlasRegion region) { if (region.packedWidth == region.originalWidth && region.packedHeight == region.originalHeight) { if (region.rotate) { Sprite sprite = new Sprite(region); sprite.setBounds(0, 0, region.getRegionHeight(), region.getRegionWidth()); sprite.rotate90(true); return sprite; } return new Sprite(region); } return new AtlasSprite(region); }
private Sprite newSprite (AtlasRegion region) { if (region.packedWidth == region.originalWidth && region.packedHeight == region.originalHeight) { if (region.rotate) { Sprite sprite = new Sprite(region); sprite.setBounds(0, 0, region.getRegionHeight(), region.getRegionWidth()); sprite.rotate90(true); return sprite; } return new Sprite(region); } return new AtlasSprite(region); }