LibGDX: transform Texture to TextureRegion

Posted by FeRo2991 on Stack Overflow See other posts from Stack Overflow or by FeRo2991
Published on 2014-06-05T15:21:47Z Indexed on 2014/06/05 15:24 UTC
Read the original article Hit count: 149

Filed under:
|
|
|

I am creating a TowerDefence Game in LibGDX and am now trying to replace the old Tile with a new StaticTiledMapTile.

But to create a StaticTiledMapTile I need a TextureRegion, not a Texture.

Now I'm trying to create a TextureRegion, which contains the whole Texture, but it doesn't seem to work. It always appears distorted.

I have tried the following:

TextureRegion region = new TextureRegion(new Texture("someImg.png"), 0, 0, 32, 32);
StaticTileMapTile tile = new StaticTiledMapTile(region);
getLayer().getCell(x,y).setTile(tile); //setting the new tile

In my opinion this should work (if the image, as it is, is 32px wide and 32px high).

© Stack Overflow or respective owner

Related posts about libgdx

Related posts about textures