Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class MyAtlas extends TileAtlas {
- public MyAtlas(TiledMap map) {
- for (TileSet set : map.tileSets) {
- Texture text = new Texture(dir + "/" + set.imageName);
- int textureWidth = text.getWidth();
- int textureHeight = text.getHeight();
- AtlasRegion reg;
- int index = 0;
- for(int y = 0 ; y < textureHeight / set.tileHeight ; y++) {
- for(int x = 0 ; x < textureWidth / set.tileHeight ; x++) {
- if(x * set.tileWidth + (x * set.spacing) + set.tileWidth > text.getWidth()) continue;
- reg = new AtlasRegion(text, x * set.tileWidth + (x * set.spacing), y * set.tileHeight + (y*set.spacing), set.tileWidth, set.tileHeight);
- regionsMap.put(index + set.firstgid, reg);
- index++;
- }
- }
- }
- }
- public TextureRegion getRegion(int id) {
- return regionsMap.get(id);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment