Package com.badlogic.gdx.graphics.g2d

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


        if (!fontFile.exists()) throw new SerializationException("Font file not found: " + fontFile);

        // Use a region with the same name as the font, else use a PNG file in the same directory as the FNT file.
        String regionName = fontFile.nameWithoutExtension();
        try {
          TextureRegion region = skin.optional(regionName, TextureRegion.class);
          if (region != null)
            return new BitmapFont(fontFile, region, false);
          else {
            FileHandle imageFile = fontFile.parent().child(regionName + ".png");
            if (imageFile.exists())
View Full Code Here


    this(new TextureRegionDrawable(region), Scaling.stretch, Align.center);
  }

  /** Creates an image stretched, and aligned center. */
  public Image (Texture texture) {
    this(new TextureRegionDrawable(new TextureRegion(texture)));
  }
View Full Code Here

    float scaleX = getScaleX();
    float scaleY = getScaleY();

    if (drawable != null) {
      if (drawable.getClass() == TextureRegionDrawable.class) {
        TextureRegion region = ((TextureRegionDrawable)drawable).getRegion();
        float rotation = getRotation();
        if (scaleX == 1 && scaleY == 1 && rotation == 0)
          batch.draw(region, x + imageX, y + imageY, imageWidth, imageHeight);
        else {
          batch.draw(region, x + imageX, y + imageY, getOriginX() - imageX, getOriginY() - imageY, imageWidth, imageHeight,
View Full Code Here

  @Override
  public BitmapFont loadSync (AssetManager manager, String fileName, FileHandle file, BitmapFontParameter parameter) {
    TextureRegion[] regs = new TextureRegion[data.getImagePaths().length];
    for (int i=0; i<regs.length; i++) {
      TextureRegion region = new TextureRegion(manager.get(data.getImagePath(i), Texture.class));
      if (parameter != null) {
        region.getTexture().setFilter(parameter.minFilter, parameter.maxFilter);
      }
      regs[i] = region;
    }
    return new BitmapFont(data, regs, true);
  }
View Full Code Here

    position = new Vector2();
    velocity = new Vector2();
    faceLeft = true;
   
    // Textura del enemigo
    currentFrame = new TextureRegion(ResourceManager.getAtlas("characters/characters.pack").findRegion("enemy"));
   
    velocity.x = -1.0f;
    isAlive = true;
  }
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

   
    if(mode == GenerationMode.ByRows){
      for(int j=0; j < rows; ++j){
        int rowOffset = j*yOffset;
        for(int i=0; i < columns; ++i){
          texturePanel.unselectedRegions.add(new TextureRegion(texture, i*xOffset, rowOffset, xOffset, yOffset) );
        }
      } 
    }
    else   if(mode == GenerationMode.ByColumns){
      for(int i=0; i < columns; ++i){
        int columnOffset = i*xOffset;
        for(int j=0; j <rows; ++j){
          texturePanel.unselectedRegions.add(new TextureRegion(texture, columnOffset, j*yOffset, xOffset, yOffset) );
        }
      } 
    }
  }
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);
          if (!yUp) {
            tileRegion.flip(false, true);
          }
          TiledMapTile tile = new StaticTiledMapTile(tileRegion);
          tile.setId(id);
          tileset.putTile(id++, tile);
        }
View Full Code Here

        EventQueue.invokeLater(new Runnable() {
          public void run () {
            final ByteBuffer buffer = ByteBuffer.allocateDirect(1024 * 1024 * 4);
            buffer.order(ByteOrder.LITTLE_ENDIAN);
            fontGenerator.getTextureData(buffer.asIntBuffer());
            TextureRegion glyphRegion = new TextureRegion(new Texture(new TextureData() {
              Pixmap pixmap;

              public int getWidth () {
                return width;
              }
View Full Code Here

        batch.end();
      } else {
        glClearColor(1, 1, 1, 1);
        GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);

        TextureRegion region = font.getRegion();
        float y = viewHeight - region.getRegionHeight();

        glColor4f(renderingBackgroundColor.r, renderingBackgroundColor.g, renderingBackgroundColor.b, 0);
        glBegin(GL_QUADS);
        glVertex3f(0, y + region.getRegionHeight(), 0);
        glVertex3f(0, y, 0);
        glVertex3f(region.getRegionWidth(), y, 0);
        glVertex3f(region.getRegionWidth(), y + region.getRegionHeight(), 0);
        glEnd();

        batch.begin();
        batch.draw(region, 0, y);
        batch.end();
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.