Package com.badlogic.gdx.graphics.g2d

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


        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

        if (tile != null) {
          final boolean flipX = cell.getFlipHorizontally();
          final boolean flipY = cell.getFlipVertically();
          final int rotations = cell.getRotation();
          TextureRegion region = tile.getTextureRegion();

          float x1 = (x * tileWidth) - ((y % 2 == 1) ? halfTileWidth : 0);
          float y1 = y * halfTileHeight;
          float x2 = x1 + region.getRegionWidth() * unitScale;
          float y2 = y1 + region.getRegionHeight() * unitScale;

          float u1 = region.getU();
          float v1 = region.getV2();
          float u2 = region.getU2();
          float v2 = region.getV();

          vertices[X1] = x1;
          vertices[Y1] = y1;
          vertices[C1] = color;
          vertices[U1] = u1;
          vertices[V1] = v1;

          vertices[X2] = x1;
          vertices[Y2] = y2;
          vertices[C2] = color;
          vertices[U2] = u1;
          vertices[V2] = v2;

          vertices[X3] = x2;
          vertices[Y3] = y2;
          vertices[C3] = color;
          vertices[U3] = u2;
          vertices[V3] = v2;

          vertices[X4] = x2;
          vertices[Y4] = y1;
          vertices[C4] = color;
          vertices[U4] = u2;
          vertices[V4] = v1;

          if (flipX) {
            float temp = vertices[U1];
            vertices[U1] = vertices[U3];
            vertices[U3] = temp;
            temp = vertices[U2];
            vertices[U2] = vertices[U4];
            vertices[U4] = temp;
          }

          if (flipY) {
            float temp = vertices[V1];
            vertices[V1] = vertices[V3];
            vertices[V3] = temp;
            temp = vertices[V2];
            vertices[V2] = vertices[V4];
            vertices[V4] = temp;
          }

          if (rotations != 0) {
            switch (rotations) {
              case Cell.ROTATE_90: {
                float tempV = vertices[V1];
                vertices[V1] = vertices[V2];
                vertices[V2] = vertices[V3];
                vertices[V3] = vertices[V4];
                vertices[V4] = tempV;

                float tempU = vertices[U1];
                vertices[U1] = vertices[U2];
                vertices[U2] = vertices[U3];
                vertices[U3] = vertices[U4];
                vertices[U4] = tempU;
                break;
              }
              case Cell.ROTATE_180: {
                float tempU = vertices[U1];
                vertices[U1] = vertices[U3];
                vertices[U3] = tempU;
                tempU = vertices[U2];
                vertices[U2] = vertices[U4];
                vertices[U4] = tempU;
                float tempV = vertices[V1];
                vertices[V1] = vertices[V3];
                vertices[V3] = tempV;
                tempV = vertices[V2];
                vertices[V2] = vertices[V4];
                vertices[V4] = tempV;
                break;
              }
              case Cell.ROTATE_270: {
                float tempV = vertices[V1];
                vertices[V1] = vertices[V4];
                vertices[V4] = vertices[V3];
                vertices[V3] = vertices[V2];
                vertices[V2] = tempV;

                float tempU = vertices[U1];
                vertices[U1] = vertices[U4];
                vertices[U4] = vertices[U3];
                vertices[U3] = vertices[U2];
                vertices[U2] = tempU;
                break;
              }
            }
          }

          spriteBatch.draw(region.getTexture(), vertices, 0, 20);
        }
      }
    }
  }
View Full Code Here

        if (tile != null) {
          final boolean flipX = cell.getFlipHorizontally();
          final boolean flipY = cell.getFlipVertically();
          final int rotations = cell.getRotation();

          TextureRegion region = tile.getTextureRegion();

          float x1 = x;
          float y1 = y;
          float x2 = x1 + region.getRegionWidth() * unitScale;
          float y2 = y1 + region.getRegionHeight() * unitScale;

          float u1 = region.getU();
          float v1 = region.getV2();
          float u2 = region.getU2();
          float v2 = region.getV();

          vertices[X1] = x1;
          vertices[Y1] = y1;
          vertices[C1] = color;
          vertices[U1] = u1;
          vertices[V1] = v1;

          vertices[X2] = x1;
          vertices[Y2] = y2;
          vertices[C2] = color;
          vertices[U2] = u1;
          vertices[V2] = v2;

          vertices[X3] = x2;
          vertices[Y3] = y2;
          vertices[C3] = color;
          vertices[U3] = u2;
          vertices[V3] = v2;

          vertices[X4] = x2;
          vertices[Y4] = y1;
          vertices[C4] = color;
          vertices[U4] = u2;
          vertices[V4] = v1;

          if (flipX) {
            float temp = vertices[U1];
            vertices[U1] = vertices[U3];
            vertices[U3] = temp;
            temp = vertices[U2];
            vertices[U2] = vertices[U4];
            vertices[U4] = temp;
          }
          if (flipY) {
            float temp = vertices[V1];
            vertices[V1] = vertices[V3];
            vertices[V3] = temp;
            temp = vertices[V2];
            vertices[V2] = vertices[V4];
            vertices[V4] = temp;
          }
          if (rotations != 0) {
            switch (rotations) {
              case Cell.ROTATE_90: {
                float tempV = vertices[V1];
                vertices[V1] = vertices[V2];
                vertices[V2] = vertices[V3];
                vertices[V3] = vertices[V4];
                vertices[V4] = tempV;

                float tempU = vertices[U1];
                vertices[U1] = vertices[U2];
                vertices[U2] = vertices[U3];
                vertices[U3] = vertices[U4];
                vertices[U4] = tempU;
                break;
              }
              case Cell.ROTATE_180: {
                float tempU = vertices[U1];
                vertices[U1] = vertices[U3];
                vertices[U3] = tempU;
                tempU = vertices[U2];
                vertices[U2] = vertices[U4];
                vertices[U4] = tempU;
                float tempV = vertices[V1];
                vertices[V1] = vertices[V3];
                vertices[V3] = tempV;
                tempV = vertices[V2];
                vertices[V2] = vertices[V4];
                vertices[V4] = tempV;
                break;
              }
              case Cell.ROTATE_270: {
                float tempV = vertices[V1];
                vertices[V1] = vertices[V4];
                vertices[V4] = vertices[V3];
                vertices[V3] = vertices[V2];
                vertices[V2] = tempV;

                float tempU = vertices[U1];
                vertices[U1] = vertices[U4];
                vertices[U4] = vertices[U3];
                vertices[U3] = vertices[U2];
                vertices[U2] = tempU;
                break;
              }
            }
          }
          spriteBatch.draw(region.getTexture(), vertices, 0, 20);
        }
      }
    }
  }
View Full Code Here

        if (tile != null) {
          final boolean flipX = cell.getFlipHorizontally();
          final boolean flipY = cell.getFlipVertically();
          final int rotations = cell.getRotation();

          TextureRegion region = tile.getTextureRegion();

          float x1 = x;
          float y1 = y;
          float x2 = x1 + region.getRegionWidth() * unitScale;
          float y2 = y1 + region.getRegionHeight() * unitScale;

          float u1 = region.getU();
          float v1 = region.getV2();
          float u2 = region.getU2();
          float v2 = region.getV();

          vertices[X1] = x1;
          vertices[Y1] = y1;
          vertices[C1] = color;
          vertices[U1] = u1;
          vertices[V1] = v1;

          vertices[X2] = x1;
          vertices[Y2] = y2;
          vertices[C2] = color;
          vertices[U2] = u1;
          vertices[V2] = v2;

          vertices[X3] = x2;
          vertices[Y3] = y2;
          vertices[C3] = color;
          vertices[U3] = u2;
          vertices[V3] = v2;

          vertices[X4] = x2;
          vertices[Y4] = y1;
          vertices[C4] = color;
          vertices[U4] = u2;
          vertices[V4] = v1;

          if (flipX) {
            float temp = vertices[U1];
            vertices[U1] = vertices[U3];
            vertices[U3] = temp;
            temp = vertices[U2];
            vertices[U2] = vertices[U4];
            vertices[U4] = temp;
          }
          if (flipY) {
            float temp = vertices[V1];
            vertices[V1] = vertices[V3];
            vertices[V3] = temp;
            temp = vertices[V2];
            vertices[V2] = vertices[V4];
            vertices[V4] = temp;
          }
          if (rotations != 0) {
            switch (rotations) {
              case Cell.ROTATE_90: {
                float tempV = vertices[V1];
                vertices[V1] = vertices[V2];
                vertices[V2] = vertices[V3];
                vertices[V3] = vertices[V4];
                vertices[V4] = tempV;

                float tempU = vertices[U1];
                vertices[U1] = vertices[U2];
                vertices[U2] = vertices[U3];
                vertices[U3] = vertices[U4];
                vertices[U4] = tempU;
                break;
              }
              case Cell.ROTATE_180: {
                float tempU = vertices[U1];
                vertices[U1] = vertices[U3];
                vertices[U3] = tempU;
                tempU = vertices[U2];
                vertices[U2] = vertices[U4];
                vertices[U4] = tempU;
                float tempV = vertices[V1];
                vertices[V1] = vertices[V3];
                vertices[V3] = tempV;
                tempV = vertices[V2];
                vertices[V2] = vertices[V4];
                vertices[V4] = tempV;
                break;
              }
              case Cell.ROTATE_270: {
                float tempV = vertices[V1];
                vertices[V1] = vertices[V4];
                vertices[V4] = vertices[V3];
                vertices[V3] = vertices[V2];
                vertices[V2] = tempV;

                float tempU = vertices[U1];
                vertices[U1] = vertices[U4];
                vertices[U4] = vertices[U3];
                vertices[U3] = vertices[U2];
                vertices[U2] = tempU;
                break;
              }
            }
          }
          spriteBatch.draw(region.getTexture(), vertices, 0, 20);
          x += layerTileWidth;
        }
      }
      y += layerTileHeight;
    }
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

          final boolean flipX = cell.getFlipHorizontally();
          final boolean flipY = cell.getFlipVertically();
          final int rotations = cell.getRotation();

          TextureRegion region = tile.getTextureRegion();

          float x1 = x;
          float y1 = y;
          float x2 = x1 + region.getRegionWidth() * unitScale;
          float y2 = y1 + region.getRegionHeight() * unitScale;

          float u1 = region.getU();
          float v1 = region.getV2();
          float u2 = region.getU2();
          float v2 = region.getV();

          vertices[X1] = x1;
          vertices[Y1] = y1;
          vertices[C1] = color;
          vertices[U1] = u1;
          vertices[V1] = v1;

          vertices[X2] = x1;
          vertices[Y2] = y2;
          vertices[C2] = color;
          vertices[U2] = u1;
          vertices[V2] = v2;

          vertices[X3] = x2;
          vertices[Y3] = y2;
          vertices[C3] = color;
          vertices[U3] = u2;
          vertices[V3] = v2;

          vertices[X4] = x2;
          vertices[Y4] = y1;
          vertices[C4] = color;
          vertices[U4] = u2;
          vertices[V4] = v1;

          if (flipX) {
            float temp = vertices[U1];
            vertices[U1] = vertices[U3];
            vertices[U3] = temp;
            temp = vertices[U2];
            vertices[U2] = vertices[U4];
            vertices[U4] = temp;
          }
          if (flipY) {
            float temp = vertices[V1];
            vertices[V1] = vertices[V3];
            vertices[V3] = temp;
            temp = vertices[V2];
            vertices[V2] = vertices[V4];
            vertices[V4] = temp;
          }
          if (rotations == 2) {
            float tempU = vertices[U1];
            vertices[U1] = vertices[U3];
            vertices[U3] = tempU;
            tempU = vertices[U2];
            vertices[U2] = vertices[U4];
            vertices[U4] = tempU;
            float tempV = vertices[V1];
            vertices[V1] = vertices[V3];
            vertices[V3] = tempV;
            tempV = vertices[V2];
            vertices[V2] = vertices[V4];
            vertices[V4] = tempV;
            break;
          }
          spriteBatch.draw(region.getTexture(), vertices, 0, 20);
        }
      }
    }
   
  }
View Full Code Here

   
    batch = new SpriteBatch();
    font = new BitmapFont();
    font.setColor(Color.RED);
   
    textureRegion = new TextureRegion(new Texture(
        Gdx.files.internal("data/marble.png")));
    bg = new Texture(Gdx.files.internal("data/bg.png"));

    createPhysicsWorld();
    Gdx.input.setInputProcessor(this);
View Full Code Here

                if (tile != null) {
                    final boolean flipX = cell.getFlipHorizontally();
                    final boolean flipY = cell.getFlipVertically();
                    final int rotations = cell.getRotation();

                    TextureRegion region = tile.getTextureRegion();

                    float x1 = x;
                    float y1 = y;
                    float x2 = x1 + region.getRegionWidth() * unitScale;
                    float y2 = y1 + region.getRegionHeight() * unitScale;

                    float u1 = region.getU();
                    float v1 = region.getV2();
                    float u2 = region.getU2();
                    float v2 = region.getV();

                    vertices[X1] = x1;
                    vertices[Y1] = y1;
                    vertices[C1] = color;
                    vertices[U1] = u1;
                    vertices[V1] = v1;

                    vertices[X2] = x1;
                    vertices[Y2] = y2;
                    vertices[C2] = color;
                    vertices[U2] = u1;
                    vertices[V2] = v2;

                    vertices[X3] = x2;
                    vertices[Y3] = y2;
                    vertices[C3] = color;
                    vertices[U3] = u2;
                    vertices[V3] = v2;

                    vertices[X4] = x2;
                    vertices[Y4] = y1;
                    vertices[C4] = color;
                    vertices[U4] = u2;
                    vertices[V4] = v1;

                    if (flipX) {
                        float temp = vertices[U1];
                        vertices[U1] = vertices[U3];
                        vertices[U3] = temp;
                        temp = vertices[U2];
                        vertices[U2] = vertices[U4];
                        vertices[U4] = temp;
                    }
                    if (flipY) {
                        float temp = vertices[V1];
                        vertices[V1] = vertices[V3];
                        vertices[V3] = temp;
                        temp = vertices[V2];
                        vertices[V2] = vertices[V4];
                        vertices[V4] = temp;
                    }
                    if (rotations != 0) {
                        switch (rotations) {
                            case TiledMapTileLayer.Cell.ROTATE_90: {
                                float tempV = vertices[V1];
                                vertices[V1] = vertices[V2];
                                vertices[V2] = vertices[V3];
                                vertices[V3] = vertices[V4];
                                vertices[V4] = tempV;

                                float tempU = vertices[U1];
                                vertices[U1] = vertices[U2];
                                vertices[U2] = vertices[U3];
                                vertices[U3] = vertices[U4];
                                vertices[U4] = tempU;
                                break;
                            }
                            case TiledMapTileLayer.Cell.ROTATE_180: {
                                float tempU = vertices[U1];
                                vertices[U1] = vertices[U3];
                                vertices[U3] = tempU;
                                tempU = vertices[U2];
                                vertices[U2] = vertices[U4];
                                vertices[U4] = tempU;
                                float tempV = vertices[V1];
                                vertices[V1] = vertices[V3];
                                vertices[V3] = tempV;
                                tempV = vertices[V2];
                                vertices[V2] = vertices[V4];
                                vertices[V4] = tempV;
                                break;
                            }
                            case TiledMapTileLayer.Cell.ROTATE_270: {
                                float tempV = vertices[V1];
                                vertices[V1] = vertices[V4];
                                vertices[V4] = vertices[V3];
                                vertices[V3] = vertices[V2];
                                vertices[V2] = tempV;

                                float tempU = vertices[U1];
                                vertices[U1] = vertices[U4];
                                vertices[U4] = vertices[U3];
                                vertices[U3] = vertices[U2];
                                vertices[U2] = tempU;
                                break;
                            }
                        }
                    }
                    spriteBatch.draw(region.getTexture(), vertices, 0, 20);
                    x += layerTileWidth;
                }
            }
            y -= layerTileHeight;
        }
View Full Code Here

        public AtlasRegion atlasRegion;
                   
        public final void loadFromFile (String fileName) {
            Texture texture = new Texture(Gdx.files.internal(fileName));

            image = new TextureRegion(texture, 0, 0, texture.getWidth(), texture.getHeight());
            //image.flip(false, true);
        }
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.