Tiled collection of images swapped when loaded into Corona SDK using Ponytiled

I followed a video by CoronaGeek on how to load a map into Corona SDK using Ponytiled. I made my own collection of images and created a tileset in Tiled. Then I created an object layer and built my map. When I load the map into Corona SDK using Ponytiled, the images I created are swapped with each other. The map layout remains but the images are swapped with each other.

This is my code:

local ccx,ccy,cw,ch,acw,ach = display.contentCenterX, display.contentCenterY, display.contentWidth, display.contentHeight, display.actualContentWidth, display.actualContentHeight local tiled = require "com.ponywolf.ponytiled" local mapData = require "flatmap" local map = tiled.new(mapData) map.x,map.y = ccx - map.designedWidth/2, ccy - map.designedHeight/2

And that’s all I have in my code. Nothing surprising. Any help is highly appreciated.

I have attached 3 images, my tiled view of the map, my code, and my corona sdk view… Hope this gives an idea on what’s wrong.

I followed a video by CoronaGeek on how to load a map into Corona SDK using Ponytiled. I made my own collection of images and created a tileset in Tiled. Then I created an object layer and built my map. When I load the map into Corona SDK using Ponytiled, the images I created are swapped with each other. The map layout remains but the images are swapped with each other.

This is my code:

local ccx,ccy,cw,ch,acw,ach = display.contentCenterX, display.contentCenterY, display.contentWidth, display.contentHeight, display.actualContentWidth, display.actualContentHeight local tiled = require “com.ponywolf.ponytiled” local mapData = require “flatmap” local map = tiled.new(mapData) map.x,map.y = ccx - map.designedWidth/2, ccy - map.designedHeight/2

And that’s all I have in my code. Nothing surprising. Any help is highly appreciated.

I have attached 3 images, my tiled view of the map, my code, and my corona sdk view… Hope this gives an idea on what’s wrong.

VERY URGENT. I COULDN’T FIND ANY SOLUTIONS.

I seem the remember a similar thread over the past couple of weeks. You might want to look back over the past couple of weeks and see if there is a solution offered there.

Rob

I just checked the lua file of the map. The IDs of the objects started from 0. I changed it so that it starts from 1 and goes on, it works fine. But now the problem is, whenever I export the map after making some changes to it in tiled, the IDs still start from 0. I don’t want to change them all the time I export a map + it’s time consuming when I have more objects in my file. How do I solve it? Is there any options in Tiled to solve it?

Maybe you can augment all of the indexes by 1 - What is the process for exporting them?  Do you use lua files or something like XML or JSON?

I used lua. Augmenting by 1 works but when I make changes in tiled and export them again, it comes back to the same issue.

You might want to reach out to the tiled developer and see if he can have the Lua export use 1 based indexes since that’s the language default.

Rob

Perhaps you could write a module to adjusts the values before they are viewed on the target platform.  I’ve done something like this for JSON files before - it essentially adds another step, which is annoying, but works.

My reco is to use JSON files and not the lua import. There is some code in there to recognize a lua table and start the import from 1 vs. 0, but it always seems to break.

The lines are…

 for t = 1, #tileset.tiles do local tile = tileset.tiles[t] if tonumber(tile.id) == gid - firstgid + (data.luaversion and 1 or 0) then return tile.image, flip -- may need updating with documents directory end end

If you can get them working for you…

I followed a video by CoronaGeek on how to load a map into Corona SDK using Ponytiled. I made my own collection of images and created a tileset in Tiled. Then I created an object layer and built my map. When I load the map into Corona SDK using Ponytiled, the images I created are swapped with each other. The map layout remains but the images are swapped with each other.

This is my code:

local ccx,ccy,cw,ch,acw,ach = display.contentCenterX, display.contentCenterY, display.contentWidth, display.contentHeight, display.actualContentWidth, display.actualContentHeight local tiled = require “com.ponywolf.ponytiled” local mapData = require “flatmap” local map = tiled.new(mapData) map.x,map.y = ccx - map.designedWidth/2, ccy - map.designedHeight/2

And that’s all I have in my code. Nothing surprising. Any help is highly appreciated.

I have attached 3 images, my tiled view of the map, my code, and my corona sdk view… Hope this gives an idea on what’s wrong.

VERY URGENT. I COULDN’T FIND ANY SOLUTIONS.

I seem the remember a similar thread over the past couple of weeks. You might want to look back over the past couple of weeks and see if there is a solution offered there.

Rob

I just checked the lua file of the map. The IDs of the objects started from 0. I changed it so that it starts from 1 and goes on, it works fine. But now the problem is, whenever I export the map after making some changes to it in tiled, the IDs still start from 0. I don’t want to change them all the time I export a map + it’s time consuming when I have more objects in my file. How do I solve it? Is there any options in Tiled to solve it?

Maybe you can augment all of the indexes by 1 - What is the process for exporting them?  Do you use lua files or something like XML or JSON?

I used lua. Augmenting by 1 works but when I make changes in tiled and export them again, it comes back to the same issue.

You might want to reach out to the tiled developer and see if he can have the Lua export use 1 based indexes since that’s the language default.

Rob

Perhaps you could write a module to adjusts the values before they are viewed on the target platform.  I’ve done something like this for JSON files before - it essentially adds another step, which is annoying, but works.

My reco is to use JSON files and not the lua import. There is some code in there to recognize a lua table and start the import from 1 vs. 0, but it always seems to break.

The lines are…

 for t = 1, #tileset.tiles do local tile = tileset.tiles[t] if tonumber(tile.id) == gid - firstgid + (data.luaversion and 1 or 0) then return tile.image, flip -- may need updating with documents directory end end

If you can get them working for you…