/** * Creates a tileset from a buffered image. Tiles are cut by the passed cutter. * * @param tileBitmap the image to be used, must not be null * @param cutter the tile cutter, must not be null */ private void importTileBitmap(BufferedImage tileBitmap, TileCutter cutter) { assert tileBitmap != null; assert cutter != null; tileCutter = cutter; tileSetImage = tileBitmap; cutter.setImage(tileBitmap); tileDimensions = new Rectangle(cutter.getTileDimensions()); if (cutter instanceof BasicTileCutter) { BasicTileCutter basicTileCutter = (BasicTileCutter) cutter; tileSpacing = basicTileCutter.getTileSpacing(); tileMargin = basicTileCutter.getTileMargin(); tilesPerRow = basicTileCutter.getTilesPerRow(); } Image tileImage = cutter.getNextTile(); while (tileImage != null) { Tile tile = new Tile(); tile.setImage(tileImage); addNewTile(tile); tileImage = cutter.getNextTile(); } }
public void loadFromProject(String name, TMXMap tmxMap, int tileWidth, int tileHeight) { sheet = tmxMap.getProject().getSpritesheet(name); tileDimensions.width = tileWidth; tileDimensions.height = tileHeight; int i = 0; Image tileImage = sheet.getImage(i); while (tileImage != null) { Tile tile = new Tile(); // tile.setImage(tileImage); addNewTile(tile); i++; tileImage = sheet.getImage(i); } }