Package com.badlogic.gdx.graphics.g2d

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


      public TextureRegion read (Json json, Object jsonData, Class type) {
        int x = json.readValue("x", int.class, jsonData);
        int y = json.readValue("y", int.class, jsonData);
        int width = json.readValue("width", int.class, jsonData);
        int height = json.readValue("height", int.class, jsonData);
        return new TextureRegion(skin.data.texture, x, y, width, height);
      }
    });

    json.setSerializer(BitmapFont.class, new Serializer<BitmapFont>() {
      public void write (Json json, BitmapFont font, Class valueType) {
View Full Code Here


  @Override
  public void draw (SpriteBatch batch, float parentAlpha) {
    final BitmapFont font = style.font;
    final Color fontColor = style.fontColor;
    final NinePatch background = style.background;
    final TextureRegion selection = style.selection;
    final NinePatch cursorPatch = style.cursor;

    batch.setColor(color.r, color.g, color.b, color.a * parentAlpha);
    background.draw(batch, x, y, width, height);
    float textY = (int)(height / 2) + (int)(textBounds.height / 2) + font.getDescent() / 2;
View Full Code Here

  public void layout () {
  }

  @Override
  public void draw (SpriteBatch batch, float parentAlpha) {
    final TextureRegion knob = style.knob;
    final NinePatch slider = style.slider;

    batch.setColor(color.r, color.g, color.b, color.a * parentAlpha);
    sliderPos = (value - min) / (max - min) * (width - knob.getRegionWidth());
    sliderPos = Math.max(0, sliderPos);
    sliderPos = Math.min(width - knob.getRegionWidth(), sliderPos);

    float maxHeight = Math.max(knob.getRegionHeight(), slider.getTotalHeight());
    slider.draw(batch, x, y + (int)((maxHeight - slider.getTotalHeight()) * 0.5f), width, slider.getTotalHeight());
    batch.draw(knob, x + sliderPos, y + (int)((maxHeight - knob.getRegionHeight()) * 0.5f));
  }
 
View Full Code Here

  public void touchDragged (float x, float y, int pointer) {
    calculateSliderPosAndValue(x);
  }

  private void calculateSliderPosAndValue (float x) {
    final TextureRegion knob = style.knob;

    sliderPos = x - knob.getRegionWidth() / 2;
    sliderPos = Math.max(0, sliderPos);
    sliderPos = Math.min(width - knob.getRegionWidth(), sliderPos);
    value = min + (max - min) * (sliderPos / (width - knob.getRegionWidth()));
    if (listener != null) listener.changed(this, getValue());
  }
View Full Code Here

     */
    public SpriteGDX(String path, Rectangle rectangle, int frame) {
        m_path = new File(path).getAbsolutePath();
        FileHandle f = Gdx.files.absolute(m_path);
        m_texture = new Texture(f);
        m_region = new TextureRegion(m_texture, rectangle.x, rectangle.y, rectangle.width, rectangle.height);
        m_rectangle = rectangle;
        m_frame = frame;
    }
View Full Code Here

    }

    public void setFrame(int frame) {
        int current = Math.max(1, Math.min(frame, m_frame)) - 1;
        int dx = current * m_rectangle.width;
        m_region = new TextureRegion(m_texture, m_rectangle.x + dx, m_rectangle.y, m_rectangle.width, m_rectangle.height);
    }
View Full Code Here

  /**
   * Load the textures, initialize the TextureRegions
   */
  private void loadTextures(){
    texture = new Texture(Gdx.files.internal("data/png.png"));
    texFireButton = new TextureRegion(texture, 0, 0, 64, 16);
    texArrow = new TextureRegion(texture, 65, 0, 8, 16);
    texTank = new TextureRegion(texture, 83, 0, 32, 16);
    texCannon = new TextureRegion(texture, 159, 0, 16, 8);
   
    // Set up weapons
    texWeapons = new TextureRegion[5];
    // BigShot
    texWeapons[0] = new TextureRegion(texture,116,0,16,16);
    // Shot
    texWeapons[1] = new TextureRegion(texture,133,0,8,8);
    // Sniper
    texWeapons[2] = new TextureRegion(texture,142,0,4,4);
    // Rocket
    texWeapons[3] = new TextureRegion(texture,147,0,8,16);
    // Laser
    texWeapons[4] = new TextureRegion(texture,156,0,2,8);
   
    font = new BitmapFont(Gdx.files.internal("data/arial12.fnt"),
             Gdx.files.internal("data/arial12.png"), false);
  }
View Full Code Here

      else
        hasChanged = false;
     
      //Draws the pixmap to the texture
      texture.draw(pixmap, 0, 0);
      region = new TextureRegion(texture, 0, 0, 800, 480);
     
      //Disposes of the pixmap
        pixmap.dispose()
    }
  }
View Full Code Here

      pixmap.drawLine(i, Skitg.HEIGHT, i, Skitg.HEIGHT - peaks[i]);
    }

    //Draws the pixmap to the texture
    texture.draw(pixmap, 0, 0);
    region = new TextureRegion(texture, 0, 0, 800, 480);
   
    //Disposes of the pixmap
      pixmap.dispose();   
   
  }
View Full Code Here

        imageWidth = element.getChildByName("image").getIntAttribute("width", 0);
        imageHeight = element.getChildByName("image").getIntAttribute("height", 0);
        image = getRelativeFileHandle(tmxFile, imageSource);
      }

      TextureRegion texture = imageResolver.getImage(image.path());

      TiledMapTileSet tileset = new TiledMapTileSet();
      MapProperties props = tileset.getProperties();
      tileset.setName(name);
      props.put("firstgid", firstgid);
      props.put("imagesource", imageSource);
      props.put("imagewidth", imageWidth);
      props.put("imageheight", imageHeight);
      props.put("tilewidth", tilewidth);
      props.put("tileheight", tileheight);
      props.put("margin", margin);
      props.put("spacing", spacing);

      int stopWidth = texture.getRegionWidth() - tilewidth;
      int stopHeight = texture.getRegionHeight() - tileheight;

      int id = firstgid;

      for (int y = margin; y <= stopHeight; y += tileheight + spacing) {
        for (int x = margin; x <= stopWidth; x += tilewidth + spacing) {
          TextureRegion tileRegion = new TextureRegion(texture, x, y, tilewidth, tileheight);
          TiledMapTile tile = new StaticTiledMapTile(tileRegion);
          tile.setId(id);
          tile.setOffsetX(offsetX);
          tile.setOffsetY(-offsetY);
          tileset.putTile(id++, tile);
View Full Code Here

TOP

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

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.