Jump to content

Isometric Plugin - Tile Positions


Huggz
 Share

Recommended Posts

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

  • 2 weeks later...

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 size

This 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

  • 4 months later...
  • 2 weeks later...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...