Hello Guest

Author Topic: Using pixels per meter other than 100 messes up placing of tiles in TileMap  (Read 3091 times)

pangyan

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 5
    • View Profile
When I use a pixel per meter setting of 100, TileMap works perfectly. However I create a camera with a pixels per meter setting of say 20 and then create a spritesheet I get the following overlap in the tiles in my TileMap:



I'm dynamically loading up my TileMap using the following code:
    // Use this for initialization
    void Start()
    {
        Map map = new Map("Assets/Levels/test-load-level.tmx");
        tk2dTileMap tk2dTileMap = GameObject.FindObjectOfType<tk2dTileMap>();

        for (int layerIndex = 0; layerIndex < map.Layers.Count; layerIndex++)
        {
            foreach (Tile tile in map.Layers[layerIndex].Tiles.Values)
            {
                // Tiled's Gids are 1-based whereas 2D Toolkit's tiles are 0-based
                tk2dTileMap.SetTile(tile.X, tile.Y, layerIndex, (int)tile.Gid - 1);
            }
        }

        tk2dTileMap.ForceBuild();
    }

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
The tile size is set up in the settings panel. If you change size on the sprite collection, you'll need to reset the tile size for it to detect the size from the sprite collection. Once you do that it should be fine.