Issue with Tiled

Thanks for the info. I’ll try RGTiled.

Are you saving as CSV or as TMX? 
TMX is an xml format and loads fine with most loaders (I’m using Million Tiled Engine for my project).

BTW, great art work!

I export my file from Tiled with the .lua extension and I get an error using it with the Corona Simulator. Exporting as tmx gives me an error of my map not found because I think it expects a lua file.

Hi labbe.dom,

Make sure you select CSV in map options for Tile Layer Format.

w2SImSf.png

Have a nice day:)

EDIT: Ponytiled supports only .LUA and .JSON format map.

ldurniat

My tile layer format is always set to CSV and I still get the same error.

https://pasteboard.co/HuLUM4B.png

Use map in .JSON format (not tested, check paths) :

local tiled = require( "com.ponywolf.ponytiled" ) local json = require( "json" ) -- Load map local mapData = json.decodeFile( system.pathForFile( "assets/maps/map1.json", system.ResourceDirectory ) ) map = tiled.new( mapData , "assets/maps/map1" ) map.x, map.y = display.contentCenterX, display.contentCenterY

Note:

  • Ponytiled don’t support collection of images for external tilesets (TSX files)
  • Use embeded tilesets. Mark ‘Embed in map’. 

I use Tiled v. 1.1.5

Now I only get the error of my image not being found even though it’s located in the right folder.

https://pasteboard.co/HuMrIJh.png

Thanks for the help by the way.

You should use new path

map = tiled.new( mapData , "assets/maps" )

Do you use latest version of Ponytiled from github?

local tiled = require( "com.ponywolf.ponytiled" ) local json = require( "json" ) -- Load map local mapData = json.decodeFile( system.pathForFile( "assets/maps/map1.json", system.ResourceDirectory ) ) map = tiled.new( mapData , "assets/maps" ) map.x, map.y = display.contentCenterX, display.contentCenterY

I still have the same error. It can’t find the image.  :huh:

Yes I do use the latest version of Ponytiled.

@labbe.dom - Out of curiosity, what genre/style of game are you working on?  i.e. Plat former, Shooter, Rogue-like, …

Right now it’s not decided. I’m just trying to understand the basics and exporting a map from Tiled to Corona.

Hi…did you tried to use an Object layer in Tiled?

Best regards,

Erich.

@egruttner I added an object layer to my map but I can’t use my tileset with it. I still get the same error.

WARNING: E:\Program Files (x86)\Corona Labs\Projects\Test\com\ponywolf\ponytiled.lua:176: Failed to find image ‘E:/Program Files (x86)/Corona Labs/Projects/Test/assets/maps/ground0.png’

Your problem is related with how Tiled manage paths to tilesets. 

From Tiled forum : 

Why doesn’t Tiled use the absolute path of the image?

@bjorn: It uses relative paths to make sure the map files are portable from one machine to another, or can be moved to different directories (along with their tilesets) on the same machine. 

The assumption is that you’ll put your maps and tilesets together in some folder. They can be further organized into subfolders, but they’re expected to share some common parent folder, like a folder for your project.

I recommended you follow suggestion of @bjorn above.

Solution (step by step):

  1. Create new map in assets/maps/ in Tiled,
  2. Create new tileset with name ‘collection’ (collection of images) and mark ‘Embed in map’,
  3. Add images to tileset. All images should be in assets/maps/ folder,
  4. Create a new Object Layer,
  5. Add new objects to the  Object Layer

For more details see attached project.

Note: I found bug in Ponytiled. Path for tiles (on tile layers) is incorrect. Issueon Github.

Have a nice day:)

ldurniat

@Idurniat I followed your steps using your attached project and my images. It didn’t work. I am out of ideas so I’m giving you back your Tiled test.zip along with my images. Maybe the problem comes from them.

I have no idea how to upload a file in a reply so you can download my file here https://www101.zippyshare.com/v/G50ussDD/file.html

Here is the link to my Tiled map https://www101.zippyshare.com/v/8hLO4hLn/file.html

Edit: I just realized your map is made entirely with objects and mine was made with a tile layer. I think this is the issue. Now I am trying to figure out how to drag in my images as objects.

I got it working. Just had to use my tiles as objects with the insert tile button. Thanks everyone.

I tried adding collisions to my map but it seems to work with tiles only. Even if my map is made of objects only, as soon as I add one tile I get the error of my image not being found. It seems that making a map with objects only is not the answer.

What am I missing? What’s the difference between a tile and an object?

@labbe.dom,

I’m working on a Tiled starter that is similar to PonyWolf’s pipeline, but has my own twist on things.

If you can wait till Monday next week, I’d suggest checking it out.

The first ‘game’ I’ll be showing how to make will be a single screen platformer.  Then, I’ll move on to multi-screen platformers, and if the community shows any interest I’ll take it to other game styles from there.

The idea is that this will be something you can try before you buy.  I’ll be sure to keep the cost reasonable.

I had a bit of trouble on Tiled too, the biggest problem was that the filenames were wrong, I had to go into the files and change them all manually.

You can use collision for objects but I’m not sure about tiles (on Tile Layers).

See how collision detection works in Sticker-Knight-Platformer (it uses only Object Layers as I remember) game. Look for scene/game/lib.hero.lua and game.lua files.

Basically you need :

  1. Set path to custom modules

  2. Extend your object using custom code.

  3. Write your own module. See hero.lua module from game mentioned above.

    map.extensions = “scene.game.lib.” map:extend( “hero” )

To fix your problem with tiles not  being found use my solution proposed in my last issue on https://github.com/ponywolf/ponytiled/issues/13.

Good luck:)

I think you’re going to stick with Berry, but FYI the RGTiled update is out.  

https://forums.coronalabs.com/topic/73409-rg-tiled-behaviors-entity-component-system/