ponywolf / ponytiled

PonyTiled a simple Tiled Map Loader for Corona SDK
MIT License
83 stars 22 forks source link

The tileset field don’t include columns field in lua export #11

Closed ldurniat closed 6 years ago

ldurniat commented 6 years ago

Hi,

I did not use lua export at all until yesterday so I don't notice it ealier. The columns field is not present in lua export. I find this code useful for me:

  local function loadTileset(num)
    local tileset = tilesets[num]

    local tsiw, tsih = tileset.imagewidth, tileset.imageheight
    local margin, spacing = tileset.margin or 0, tileset.spacing or 0
    local w, h = tileset.tilewidth, tileset.tileheight
    local columns = (tsiw - margin + spacing) / (w + spacing)  -- Added code
    local gid = 0

    local options = {
      frames = {},
      sheetContentWidth =  tsiw,
      sheetContentHeight = tsih,
    }

    local frames = options.frames
    local tsh = tileset.tilecount / columns -- Added code
    local tsw = columns -- Added code
    ...
}

Of course, the columns field is present in external tilesets (*.tsx).

Have a nice day:) ldurniat

MDrollette commented 6 years ago

This has been fixed on master in Tiled https://github.com/bjorn/tiled/pull/1969

ldurniat commented 6 years ago

@MDrollette : Thanks for information.

superqix commented 6 years ago

Cleaning up the issues today :)