Package com.badlogic.gdx.graphics.g2d

Examples of com.badlogic.gdx.graphics.g2d.Sprite


    return t;
  }

  public static Sprite newSprite( String textureName ) {
    Sprite s = new Sprite( newTexture( textureName, false ) );
    s.flip( false, true );
    return s;
  }
View Full Code Here


                    return index1 - index2;
                }
            });
            final Array<Sprite> sprites = new Array<Sprite>();
            for(String spriteName : spriteNames) {
                Sprite sprite = textureAtlas.createSprite(spriteName);
                sprite.setSize(Units.instance.getUnits(sprite.getWidth()), Units.instance.getUnits(sprite.getHeight()));
                sprite.setOrigin(sprite.getWidth() * .5f, sprite.getHeight() * .5f);
                sprites.add(sprite);
            }
            Animation animation = new Animation(fps, sprites);
            animations.put(name, animation);
            return animation;
View Full Code Here

        }
        return null;
    }

    private Sprite createSprite(String name) {
        Sprite sprite = textureAtlas.createSprite(name);
        sprite.setSize(Units.instance.getUnits(sprite.getWidth()), Units.instance.getUnits(sprite.getHeight()));
        sprite.setOrigin(sprite.getWidth() * .5f, sprite.getHeight() * .5f);
        if(sprite != null) {
            sprites.put(name, sprite);
        }
        return sprite;
    }
View Full Code Here

     * @param name
     *         The sprite name.
     * @return The sprite if it exists; otherwise, null.
     */
    public Sprite getSprite(String name) {
        Sprite sprite = sprites.get(name);
        if(sprite == null) {
            sprite = createSprite(name);
        }
        return sprite;
    }
View Full Code Here

  @Override
  public void show() {
    // TODO Auto-generated method stub
    splashTexture = new Texture("data/screens/Untitled.png");
    splashTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
    splashSprite = new Sprite(splashTexture);
    splashSprite.setColor(1, 1, 1, 0);
    splashSprite.setX(Gdx.graphics.getWidth() / 2 - (splashSprite.getWidth() / 2));
    splashSprite.setY(Gdx.graphics.getHeight() / 2 - (splashSprite.getHeight() / 2));

    batch = new SpriteBatch();
View Full Code Here

  @Override
  public void show() {
    splashTexture = new Texture("data/splashscreen.png");
    splashTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
   
    splashSprite = new Sprite(splashTexture);
    splashSprite.setColor(1, 1, 1, 0);
    splashSprite.setX(Gdx.graphics.getWidth() / 2 - (splashSprite.getWidth() / 2));
    splashSprite.setY(Gdx.graphics.getHeight() / 2 - (splashSprite.getHeight() / 2));
   
    batch = new SpriteBatch();
View Full Code Here

    } catch (IOException e) {
      e.printStackTrace();
    }
   
    Texture ballTexture = new Texture(Gdx.files.internal("data/particle.png"));
    Sprite ball = new Sprite(ballTexture);
    exhaust.setSprite(ball);
    exhaust.getScale().setHigh(0.3f);
    exhaust.start();
  }
View Full Code Here

  /** 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);
    }
View Full Code Here

    if (drawable == null) {
      NinePatch patch = optional(name, NinePatch.class);
      if (patch != null)
        drawable = new NinePatchDrawable(patch);
      else {
        Sprite sprite = optional(name, Sprite.class);
        if (sprite != null)
          drawable = new SpriteDrawable(sprite);
        else
          throw new GdxRuntimeException("No Drawable, NinePatch, TextureRegion, Texture, or Sprite registered with name: "
            + name);
View Full Code Here

  /** Returns a tinted copy of a drawable found in the skin via {@link #getDrawable(String)}. */
  public Drawable newDrawable (Drawable drawable, Color tint) {
    if (drawable instanceof TextureRegionDrawable) {
      TextureRegion region = ((TextureRegionDrawable)drawable).getRegion();
      Sprite sprite;
      if (region instanceof AtlasRegion)
        sprite = new AtlasSprite((AtlasRegion)region);
      else
        sprite = new Sprite(region);
      sprite.setColor(tint);
      return new SpriteDrawable(sprite);
    }
    if (drawable instanceof NinePatchDrawable) {
      NinePatchDrawable patchDrawable = new NinePatchDrawable((NinePatchDrawable)drawable);
      patchDrawable.setPatch(new NinePatch(patchDrawable.getPatch(), tint));
      return patchDrawable;
    }
    if (drawable instanceof SpriteDrawable) {
      SpriteDrawable spriteDrawable = new SpriteDrawable((SpriteDrawable)drawable);
      Sprite sprite = spriteDrawable.getSprite();
      if (sprite instanceof AtlasSprite)
        sprite = new AtlasSprite((AtlasSprite)sprite);
      else
        sprite = new Sprite(sprite);
      sprite.setColor(tint);
      spriteDrawable.setSprite(sprite);
      return spriteDrawable;
    }
    throw new GdxRuntimeException("Unable to copy, unknown drawable type: " + drawable.getClass());
  }
View Full Code Here

TOP

Related Classes of com.badlogic.gdx.graphics.g2d.Sprite

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.