-
Notifications
You must be signed in to change notification settings - Fork 450
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
combineTilesets and combineTileFrames break with borders/spacing #1807
Comments
could you provide sample tilesets? and does your tilesets have the same spacing/border? |
For spacing and border I set both to 2, 2. |
Happens for me too (neko on Windows 7). |
I have just written a naive workaround. It first merges the BitmapData vertically, and then applies spacing and border. But it only works if you have the same tileset size and until you reach texture height limit I suppose... var tileSize: FlxPoint = new FlxPoint(tileMap.tileWidth, tileMap.tileHeight);
var tileSpacing: FlxPoint = new FlxPoint(2, 2);
var tileBorder: FlxPoint = new FlxPoint(2, 2);
var firstTileset = tileMap.tilesetArray[0];
var mergedTilesetBitmap: BitmapData = new BitmapData(firstTileset.numCols * firstTileset.tileWidth,
firstTileset.numRows * firstTileset.tileHeight * tileMap.tilesetArray.length, true);
var tilesetNumber = 0;
var copyPixelsPos = new Point();
for (tileset in tileMap.tilesetArray)
{
var tilesetBitmap: BitmapData = LoadBitmap("assets/data/" + tileset.imageSource);
copyPixelsPos.y = firstTileset.numRows * firstTileset.tileHeight * tilesetNumber;
mergedTilesetBitmap.copyPixels(tilesetBitmap, tilesetBitmap.rect, copyPixelsPos);
++tilesetNumber;
}
var mergedTileset = FlxTileFrames.fromBitmapAddSpacesAndBorders(mergedTilesetBitmap, tileSize, tileSpacing, tileBorder); |
i've modified tiledMap = new TiledMap(tiledLevel);
var tileSize:FlxPoint = FlxPoint.get(tiledMap.tileWidth, tiledMap.tileHeight);
var tileSpacing:FlxPoint = FlxPoint.get(2, 2);
var tileBorders:FlxPoint = FlxPoint.get(2, 2);
// Load tileset graphics
var tilesetBitmaps:Array<FlxTileFrames> = new Array<FlxTileFrames>();
for (tileset in tiledMap.tilesetArray) {
var imagePath = new Path(tileset.imageSource);
var processedPath = TILESET_PATH + imagePath.file + "." + imagePath.ext;
tilesetBitmaps.push(FlxTileFrames.fromRectangle(processedPath, tileSize);
}
// Combine tilesets into single tileset
var combinedTileset:FlxTileFrames = FlxTileFrames.combineTileFrames(tilesetBitmaps, tileSpacing, tileBorders);
tileSize.put();
tileSpacing.put();
tileBorders.put(); |
Works great, thanks! |
Yes, it seems to work neat, thanks! |
When trying to merge tilesets and add the spacing/border to tiles, the tilemap does not render. See figure 1. Tilemap loads fine with the given code, but if you change the FlxPoint values to anything more than 0 it breaks. It seems that
combineTilesets
andcombineTileFrames
do not take into account the spacing, and so it seems there is no way to use merged tilesets and also have the border/spacing.@Beeblerox
The text was updated successfully, but these errors were encountered: