LibGDX: transform Texture to TextureRegion
- by FeRo2991
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).