Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Issue with Tiled
Started by labbe.dom Jul 16 2018 01:05 AM

20 replies to this topic
[TOPIC CONTROLS]
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

labbe.dom

[GLOBAL: userInfoPane.html]
labbe.dom
  • Observer

  • 10 posts
  • Corona SDK

Hi, I am new to using Corona and Tiled and I have a problem with a map I exported.

 

This is the code I have:

 

local tiled = require ("com.ponywolf.ponytiled")
local mapData = require ("assets.maps.map1")
 
local map = tiled.new(mapData, "assets/maps/map1")
map.x,map.y = display.contentCenterX, display.contentCenterY
 
And this is the error I get:
 
ERROR: Tile layer encoding/compression not supported. Choose CSV or XML in map options.
 

I made sure to pick CSV in the options when making my map and it is located in the right folder.

I have included the image I am trying to use and the message appearing when the error occurs.

 

Any help please?

Attached Files



[TOPIC: post.html]
#2

Dr Brian Burton

[GLOBAL: userInfoPane.html]
Dr Brian Burton
  • Enthusiast

  • 74 posts
  • Corona SDK

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!



[TOPIC: post.html]
#3

labbe.dom

[GLOBAL: userInfoPane.html]
labbe.dom
  • Observer

  • 10 posts
  • Corona SDK

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.



[TOPIC: post.html]
#4

ldurniat

[GLOBAL: userInfoPane.html]
ldurniat
  • Contributor

  • 389 posts
  • Corona SDK

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


Edited by ldurniat, 16 July 2018 - 12:34 PM.


[TOPIC: post.html]
#5

labbe.dom

[GLOBAL: userInfoPane.html]
labbe.dom
  • Observer

  • 10 posts
  • Corona SDK

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

 

https://pasteboard.co/HuLUM4B.png



[TOPIC: post.html]
#6

ldurniat

[GLOBAL: userInfoPane.html]
ldurniat
  • Contributor

  • 389 posts
  • Corona SDK

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


Edited by ldurniat, 16 July 2018 - 02:00 PM.


[TOPIC: post.html]
#7

labbe.dom

[GLOBAL: userInfoPane.html]
labbe.dom
  • Observer

  • 10 posts
  • Corona SDK

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.



[TOPIC: post.html]
#8

ldurniat

[GLOBAL: userInfoPane.html]
ldurniat
  • Contributor

  • 389 posts
  • Corona SDK

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

You should use new path

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

Do you use latest version of Ponytiled from github?


Edited by ldurniat, 16 July 2018 - 02:19 PM.


[TOPIC: post.html]
#9

labbe.dom

[GLOBAL: userInfoPane.html]
labbe.dom
  • Observer

  • 10 posts
  • Corona SDK

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.



[TOPIC: post.html]
#10

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,491 posts
  • Corona SDK

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



[TOPIC: post.html]
#11

labbe.dom

[GLOBAL: userInfoPane.html]
labbe.dom
  • Observer

  • 10 posts
  • Corona SDK

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



[TOPIC: post.html]
#12

egruttner

[GLOBAL: userInfoPane.html]
egruttner
  • Enthusiast

  • 73 posts
  • Corona SDK

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

 

Best regards,

 

Erich.



[TOPIC: post.html]
#13

labbe.dom

[GLOBAL: userInfoPane.html]
labbe.dom
  • Observer

  • 10 posts
  • Corona SDK

@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'



[TOPIC: post.html]
#14

ldurniat

[GLOBAL: userInfoPane.html]
ldurniat
  • Contributor

  • 389 posts
  • Corona SDK

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. Issue on Github.

 

Have a nice day:)

 

ldurniat

Attached Files


Edited by ldurniat, 17 July 2018 - 06:55 AM.


[TOPIC: post.html]
#15

labbe.dom

[GLOBAL: userInfoPane.html]
labbe.dom
  • Observer

  • 10 posts
  • Corona SDK

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


Edited by labbe.dom, 17 July 2018 - 08:40 PM.


[TOPIC: post.html]
#16

labbe.dom

[GLOBAL: userInfoPane.html]
labbe.dom
  • Observer

  • 10 posts
  • Corona SDK

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?



[TOPIC: post.html]
#17

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,491 posts
  • Corona SDK

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


Edited by roaminggamer, 19 July 2018 - 01:20 PM.


[TOPIC: post.html]
#18

Blex

[GLOBAL: userInfoPane.html]
Blex
  • Corona Geek

  • 1,199 posts
  • Corona SDK

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.



[TOPIC: post.html]
#19

ldurniat

[GLOBAL: userInfoPane.html]
ldurniat
  • Contributor

  • 389 posts
  • Corona SDK

I tried adding collisions to my map but it seems to work with tiles only.

 
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" )

 

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.

 

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:)

Edited by ldurniat, 19 July 2018 - 02:13 PM.


[TOPIC: post.html]
#20

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,491 posts
  • Corona SDK

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/



[TOPIC: post.html]
#21

labbe.dom

[GLOBAL: userInfoPane.html]
labbe.dom
  • Observer

  • 10 posts
  • Corona SDK

Thanks for the info. I'll try RGTiled.




[topic_controls]
[/topic_controls]