Huggz Posted March 16, 2015 Share Posted March 16, 2015 I'm having a terrible time getting my tiles to align properly. I'm using the following routine to print them: var size = 54; var i = 0; for (var xx = 0; xx < size * this.mapData.MapWidth; xx += size) { for (var yy = 0; yy < size * this.mapData.MapHeight; yy += size) { var row = Math.floor(i / 10); var col = Math.floor(i % 10); var assetId = this.mapData.MapTiles[col][row].AssetId; var asset = this.game.AssetManager.getAssetById(assetId); tile = this.game.add.isoSprite(xx, yy, 0, asset.Name, 0, this.tileGroup); tile.smoothed = false; tile.body.moves = false; tile.snap = 1; tile._project(); tile.anchor.set(0.5, 1); console.log("Placing (" + row + "," + col + ") at (" + xx + "," + yy + ") which is (" + tile.position.x + "," + tile.position.y + ")"); if (asset.Name == "water01") { this.waterTiles.push(tile); } i++; } }But I'm still getting these little slivers of space between some tiles and noticeable nicks in the map border, no matter what I adjust size to http://imgur.com/xFt3OfN 96 x 48 is the diamond size, tiles have a 4px bottom on them making the images actually 96 x 52 I'm not really sure what the problem is. I'm not sure how to pick a good value for size... any help would be great. Thanks! Link to comment Share on other sites More sharing options...
Huggz Posted March 26, 2015 Author Share Posted March 26, 2015 I had to put this down for a while, it didn't take me this long to figure out the solution. But here's my solution, for anyone having the same problems:var x = this.mapData.TileWidth / (2 * Math.cos(this.game.iso.projectionAngle)) + this.mapData.TileHeight / (2 * Math.sin(this.game.iso.projectionAngle));var size = x / 2;console.log("Placing tile every: " + size); // now do tile placing loop incrementing by sizeThis unprojects the tile size into 2D space so I can actually know an appropriate value for size, rather than guessing or limiting myself to tile sizes that round out. Note, that game.iso.unproject does not do the same thing, because it acts on the coordinates of the rendered map. I'll probably save this value at a more global level so it's accessible more readily, but this was my initial solution. Link to comment Share on other sites More sharing options...
jorbascrumps Posted August 15, 2015 Share Posted August 15, 2015 I know this is an old thread, but I'm toying around with isometric stuff right now. Have you worked out a system using an editor like Tiled yet, or are you just keeping a dictionary of tiles and looping through them still? Link to comment Share on other sites More sharing options...
Zangarian Posted August 29, 2015 Share Posted August 29, 2015 Thank you, you helped me a lot ! Cubes of 32x32 so tiles of 32x16, spaced of 17.89 px. Link to comment Share on other sites More sharing options...
Recommended Posts