Need help using Tiled if possible

Hi. I’m new to this stuff sorry if my question isnt great. I’m trying to use tiled and just get to know it. I made a basic thing but i’m having an issue. When being ran in the simulator, it is pulling the wrong images (or non) for the spots. (you can see in the image i uploaded, the Block becomes the knight, the knight becomes the alter, and the alter doesnt show up. 

I know i’m doing some things right since I’m getting some images pulled in. I also am sure i’m making huge mistakes. (i do know i’ve been exporting/saving correctly each time)

I’ve attached a photo showing my tiled file and the correlating result in corona. (i’m just using the sticker knight items for the tileset.)

Any help would be much appreciated. (if you need more from me let me know)

Thanks a lot, 

JD

Main.lua code

– Your code here

local tiled = require “com.ponywolf.ponytiled”

local physics = require “physics”

– if you use physics bodies in your map, you must

– start() physics before you load your map

physics.start()

local mapData = require “maps.objects.test” – load from lua export

local map = tiled.new(mapData, “maps/objects”) – look for images in /maps/objects/

map.x,map.y = display.contentCenterX - map.designedWidth/2, display.contentCenterY - map.designedHeight/2

– drag the whole map for fun

local dragable = require “com.ponywolf.plugins.dragable”

map = dragable.new(map)

I’m sorry if this formatting is bad. is there anything in this that is causing it to pull the wrong png images? 

The code looks fine, I am using the ponytlled loader without issue.

It looks like you didn’t embed the tile into the map. (The second icon in on the tile window you posted). I’d try that first before looking at the rest of this. When you embed a map it becomes greyed out.

A couple of initial thoughts…

  1.  If you close the map in Tiled, then re-open it, does it still look OK? (To make sure you didn’t mess with tile names, locations etc)

  2. In Tiled, if you move each object to the right a bit, the other objects aren’t ‘underneath’ them correct? (when I overlay tiles they sporadically appear for me)

  3. Try saving the map as a JSON file and using that (just in case)

  4. Look at the JSON file with an editor, verify that the images used are correct.

  5. Are you using Object layers? While it supports others, I had the best experience with object layers.

  6. Create a quick new map, just in case.

It seems its an issue with the file paths. The problem might be in the .lua file generated by Tiled, where the file paths are wrong.

Could you post your test.lua and test.tmx files here?

Ponytiled doesn’t always work as expected. I guess it’s not made to cover all possible use cases.

For example, It didn’t display the final column of my map. You seem to have a similar index number issue. I just made a wild guess and removed “-1” from these lines (ponytiled.lua) and it worked:

[lua]for ty=0, data.height-1 do

        for tx=0, data.width-1 do[/lua]

Keep in mind that I haven’t spend any time trying to grasp the code or fix it in a competent way and I’ve most likely introduced more problems. It just appeared to have worked.

Thanks for the replies everyone!

I’m at work right now, and I think I messed with the code . I’ll add it tonight when i get home which will be late. I messed around with dusk and was having some similar issues.

I think one of the problems is with this version of tiled. Like I said I’m new to this but I’ve noticed some things with it that dont seem like they are meant to happen in this version in terms of adding tilesets. (as a collection of images)

When I go to add a tileset collection of images, It doesnt let me embed them at the time of adding the fileset. If I click that option, I cant add images for some reason. If I add the collection of images but dont embed them into the map, (and then embed them afterwards) I get the wrong images like above. 

I also messed around with dusk last night in frustration. If i added tilesets the other way (not as a collection i forgot what it was called) I could embed it into the map right away, and they would work with the SDK.

Sorry i’m not giving too much for you guys to work with but maybe its enough for you guys (you are a lot smarter than me with this stuff)

Thanks again

JD

You can add images when you embed it. You need to use the blue plus button up top to add them. I made a quick video:

https://www.youtube.com/watch?v=r6cOwNZDu-8

I have noticed that some versions of Tiled work better than others. The 1.0.1 works fine for me, but for other people, I think 0.18.0 is the best.

Oh ok… well i didnt know I would have to export the tileset to get the plus sign to show up. I’ll try that when I get home. 

I’m on Pc so I hope that doesnt make a difference… guessing it wont.

It should not.

Ok i’m home. I embeded the tileset. and am still ahving same problems…

how do i upload lua files?

after messing around with other files… it is definitely my fault… there is some directory issue going on that I’m not smart enough to figure out how to fix. Still very green in terms of the lua and coding in general…  Thanks everyone for the advice. I just need to learn how to code more i guess. 

You need to export your map using the Export As option under the category ‘File’. Then in the file type, choose lua.

Export the Lua File and post it here along with the .tmx file. To upload the lua files, use the More Reply Options button when you’re writing a post and then upload the file there.

I’m not permitted to do that yet I guess. 

hopefully this works ( I use GOogle drive)

https://drive.google.com/drive/folders/0Bx4PpUk-OCMVUGk1N3lFbDhjMG8?usp=sharing

its the whole folder of this project, feel free to tell my anything feedback wise about placing files and whatnot… i’m pretty new to all this

Sorry for not posting to this. The problem was a combination of not embedding items in map (like was suggested in advice) and potentially bad file linking. 

also I believe the tiled version being too new was an issue as well… at least thats what ponywolf tweeted at me. 

thanks to everyone for helping

The code looks fine, I am using the ponytlled loader without issue.

It looks like you didn’t embed the tile into the map. (The second icon in on the tile window you posted). I’d try that first before looking at the rest of this. When you embed a map it becomes greyed out.

A couple of initial thoughts…

  1.  If you close the map in Tiled, then re-open it, does it still look OK? (To make sure you didn’t mess with tile names, locations etc)

  2. In Tiled, if you move each object to the right a bit, the other objects aren’t ‘underneath’ them correct? (when I overlay tiles they sporadically appear for me)

  3. Try saving the map as a JSON file and using that (just in case)

  4. Look at the JSON file with an editor, verify that the images used are correct.

  5. Are you using Object layers? While it supports others, I had the best experience with object layers.

  6. Create a quick new map, just in case.

It seems its an issue with the file paths. The problem might be in the .lua file generated by Tiled, where the file paths are wrong.

Could you post your test.lua and test.tmx files here?

Ponytiled doesn’t always work as expected. I guess it’s not made to cover all possible use cases.

For example, It didn’t display the final column of my map. You seem to have a similar index number issue. I just made a wild guess and removed “-1” from these lines (ponytiled.lua) and it worked:

[lua]for ty=0, data.height-1 do

        for tx=0, data.width-1 do[/lua]

Keep in mind that I haven’t spend any time trying to grasp the code or fix it in a competent way and I’ve most likely introduced more problems. It just appeared to have worked.

Thanks for the replies everyone!

I’m at work right now, and I think I messed with the code . I’ll add it tonight when i get home which will be late. I messed around with dusk and was having some similar issues.

I think one of the problems is with this version of tiled. Like I said I’m new to this but I’ve noticed some things with it that dont seem like they are meant to happen in this version in terms of adding tilesets. (as a collection of images)

When I go to add a tileset collection of images, It doesnt let me embed them at the time of adding the fileset. If I click that option, I cant add images for some reason. If I add the collection of images but dont embed them into the map, (and then embed them afterwards) I get the wrong images like above. 

I also messed around with dusk last night in frustration. If i added tilesets the other way (not as a collection i forgot what it was called) I could embed it into the map right away, and they would work with the SDK.

Sorry i’m not giving too much for you guys to work with but maybe its enough for you guys (you are a lot smarter than me with this stuff)

Thanks again

JD