Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Tiled collection of images swapped when loaded into Corona SDK using Ponytiled
Started by sheikhameen123 Apr 05 2019 06:49 AM

8 replies to this topic

Best Answer ponywolf , 08 April 2019 - 02:22 PM

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...

[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

sheikhameen123

[GLOBAL: userInfoPane.html]
sheikhameen123
  • Observer

  • 23 posts
  • Corona SDK

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.

Attached Files



[TOPIC: post.html]
#2

sheikhameen123

[GLOBAL: userInfoPane.html]
sheikhameen123
  • Observer

  • 23 posts
  • Corona SDK

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.



[TOPIC: post.html]
#3

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 25,801 posts
  • Enterprise

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



[TOPIC: post.html]
#4

sheikhameen123

[GLOBAL: userInfoPane.html]
sheikhameen123
  • Observer

  • 23 posts
  • Corona SDK

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?



[TOPIC: post.html]
#5

sporkfin

[GLOBAL: userInfoPane.html]
sporkfin
  • Contributor

  • 500 posts
  • Corona SDK

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?



[TOPIC: post.html]
#6

sheikhameen123

[GLOBAL: userInfoPane.html]
sheikhameen123
  • Observer

  • 23 posts
  • Corona SDK

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.



[TOPIC: post.html]
#7

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 25,801 posts
  • Enterprise

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



[TOPIC: post.html]
#8

sporkfin

[GLOBAL: userInfoPane.html]
sporkfin
  • Contributor

  • 500 posts
  • Corona SDK

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.


  • roaminggamer likes this

[TOPIC: post.html]
#9

ponywolf

[GLOBAL: userInfoPane.html]
ponywolf
  • Contributor

  • 268 posts
  • Corona SDK

  Best Answer

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...


  • roaminggamer and sheikhameen123 like this


[topic_controls]
[/topic_controls]