Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Can't load Tiled Map into Corona
Started by Blex Jul 04 2017 09:05 AM

22 replies to this topic

Best Answer Blex , 05 July 2017 - 02:49 PM

Error fixed!

 

Solution: Understanding it was not an error.

[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

Blex

[GLOBAL: userInfoPane.html]
Blex
  • Corona Geek

  • 1,199 posts
  • Corona SDK

I am having problems loading my Tiled map into Corona using PonyTiled.

 

This is the error I am getting: 

Attempt to index local 'image' (a nil value)

File: com/ponywolf/ponytiled.lua
Line: 154

I don't know why this is happening, I checked that the directory of my images and files matched the tutorial he gave for Corona Geek.

 

My only code is this: 

--Require Tiled Support Library
local tiled = require "com.ponywolf.ponytiled"
local physics = require "physics"
local mapData = require "lavacave"

physics.setDrawMode("hybrid")

--Add Map Data
local map = tiled.new(mapData)

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

What could be causing this?



[TOPIC: post.html]
#2

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,516 posts
  • Corona SDK

In all likelihood you are:

 

1. missing an asset (the image in question)

 

2. your asset(s) are in the wrong place.

 

 

 

My suggestion:

 

Since you have the code, find the scritp and line in that script that is complaining (given in the error message).  Then start adding print statements and dumping out parameters (before the error) till you find the path of the 'missing' image.



[TOPIC: post.html]
#3

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,516 posts
  • Corona SDK

Tip: When first learning this.  Make a level with a single image/object. 

 

Once you've got that rendering then start making more complex stuff.

 

This approach reduces the ambiguity of what is going on.



[TOPIC: post.html]
#4

Blex

[GLOBAL: userInfoPane.html]
Blex
  • Corona Geek

  • 1,199 posts
  • Corona SDK

Well, I did get a warning too...

com/ponywolf/ponytiled.lua:153: Failed to find image 'Lava Cave Scene/lavacave/png/seperate/128/tileset/Tile (36).png'

But the image is no longer at that location and is in the same folder with all of my other images.



[TOPIC: post.html]
#5

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,516 posts
  • Corona SDK

If the image is not in the right place that is the issue.

 

However, that is a super weird name for a image.  I don't personally:

  • include spaces
  • use special charaters (, [, [, ), ], }, etc..

 

Also, that path is super-deep.   :huh:

 

 

PS - I didn't understand this sentence:

 

 

But the image is no longer at that location and is in the same folder with all of my other images.

 

Either the image is there or it isn't.



[TOPIC: post.html]
#6

Blex

[GLOBAL: userInfoPane.html]
Blex
  • Corona Geek

  • 1,199 posts
  • Corona SDK

I bought the images online and they immediately come named in this manner. And, none of the other images are having any problems.



[TOPIC: post.html]
#7

Blex

[GLOBAL: userInfoPane.html]
Blex
  • Corona Geek

  • 1,199 posts
  • Corona SDK

Ok, I replaced the old one with a new scene. There is no crash, but I don't see anything except for darkness.

 

I get an error in my logs saying: 

Tile layer encoding/compression not supported. Choose CSV or XML in map options.

However, the PonyWolf example was also exported as a lua file, so I don't know why this is appearing.



[TOPIC: post.html]
#8

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,516 posts
  • Corona SDK

I think you are making this too complicated.

 

Learn to use Tiled with a few images first.

 

I'd make a few basic examples with prototype images (just a few).  Then, when I understand how the tiled loader works I'd increase the complexity.

 

Next, organize your images and name them in a clear and meaningful way.

  • no spaces
  • consistent use of cases in file and folder names (use camelCase or snake_case, but_Not_Both)
  • no special characters
  • limited depth folder structures
  • ...

 

We've had the discussion about running too fast and I think you're doing it now.  



[TOPIC: post.html]
#9

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,516 posts
  • Corona SDK

updated post above



[TOPIC: post.html]
#10

SGS

[GLOBAL: userInfoPane.html]
SGS
  • Corona Geek

  • 1,967 posts
  • Corona SDK

crawl....walk....run....ride a bike.....drive a car....fly a plane :)



[TOPIC: post.html]
#11

Blex

[GLOBAL: userInfoPane.html]
Blex
  • Corona Geek

  • 1,199 posts
  • Corona SDK

Ok, now I don't think I can get any simpler. It's just one image, no custom properties, nothing. 

 

I am getting no error messages, no warnings in the log, just a black screen. Why....? :(

 

I tried printing out their coordinates then resetting them, and still nothing. 

 

Yes, I did try readjusting the position as necessary for it to appear properly in the center, but it is not appearing whatsoever.

 

Also:

The path for the tile images is only one folder deep.

Images properly renamed without spaces and parenthesis.

 

 

Could the problem be with the size of my tile export? I know it probably won't fit on the screen, I just want to be able to see something. 

 

Ok... I resized it so that's not the problem.  <_<



[TOPIC: post.html]
#12

gsimeonov

[GLOBAL: userInfoPane.html]
gsimeonov
  • Enthusiast

  • 43 posts
  • Corona SDK

You haven't supplied the images location in a second (missing) parameter here:

local map = tiled.new(mapData)

If you omit it, Ponytiled would look in some default folder - probably the one in that error message. So just add the folder with your tile images and it should load the map:

local map = tiled.new(mapData, "folder/images")


[TOPIC: post.html]
#13

Blex

[GLOBAL: userInfoPane.html]
Blex
  • Corona Geek

  • 1,199 posts
  • Corona SDK

Nope, still nothing. And as I said in this attempt the error messages were gone.

 

And now I know that it is not because of the version of Corona's build. I tried it out with another one... At least now I know how nice 3103 is.  :P



[TOPIC: post.html]
#14

gsimeonov

[GLOBAL: userInfoPane.html]
gsimeonov
  • Enthusiast

  • 43 posts
  • Corona SDK

Ok, I replaced the old one with a new scene. There is no crash, but I don't see anything except for darkness.

 

I get an error in my logs saying: 

Tile layer encoding/compression not supported. Choose CSV or XML in map options.

However, the PonyWolf example was also exported as a lua file, so I don't know why this is appearing.

 

Check the tile layer format of your map (Map -> Map Properties). It shouldn't be one of the Base64* options.

 

If it still doesn't work, either post screenshots of your folder structure + the latest code where you load the map, or just spend some more time digging. Studying the Sticker Knight example is not a bad idea either.



[TOPIC: post.html]
#15

Blex

[GLOBAL: userInfoPane.html]
Blex
  • Corona Geek

  • 1,199 posts
  • Corona SDK

I selected CSV and XML, but nothing is appearing. I just find it strange that the toy block sample I used to model it, was working perfectly, while this one is not. As for the file structure, the screenshot is down below.

 

And here is my updated code: 

local tiled = require "com.ponywolf.ponytiled"
local mapData = require "demo"
local physics = require "physics"

physics.start()

local map = tiled.new(mapData, "lavacavestuff")
map.x, map.y = map.x - map.designedWidth / 2, map.y - map.designedHeight / 2

if map then
   print(map.x, map.y)
end

PS, Thanks for all your help so far, @gsimeonov. (and @roaminggamer)

Attached Files



[TOPIC: post.html]
#16

gsimeonov

[GLOBAL: userInfoPane.html]
gsimeonov
  • Enthusiast

  • 43 posts
  • Corona SDK

Checklist:

  1. Is there a demo.lua file in the root project folder?
  2. Is that "lavacavestuff" folder placed directly inside the project root folder (that screenshot doesn't tell much)?
  3. It's not clear what that "designedWidth" thing is. The map should appear at the center without setting its x and y explicitly.
  4. Is the map included in a group and are you sure you haven't slapped something on top of it?


[TOPIC: post.html]
#17

Blex

[GLOBAL: userInfoPane.html]
Blex
  • Corona Geek

  • 1,199 posts
  • Corona SDK

Hi @gsimeonov, @roaminggamer PMed (Personally Messaged) me a couple of examples fixing my solution, thank you for all the help thus far. 



[TOPIC: post.html]
#18

Blex

[GLOBAL: userInfoPane.html]
Blex
  • Corona Geek

  • 1,199 posts
  • Corona SDK

  Best Answer

Error fixed!

 

Solution: Understanding it was not an error.



[TOPIC: post.html]
#19

graham07

[GLOBAL: userInfoPane.html]
graham07
  • Contributor

  • 256 posts
  • Corona SDK

@sdktester, this was a good thread, except for the reader, we didn't get a resolution. I know you did as the code was sent to you, but I was hoping to be able to leverage or learn from the issue. If there was a simple fix, its great and helpful to add it to the thread :)

 

Thanks.

 

(Now I'll go back to trying to get a level loaded into the PonyLoader )



[TOPIC: post.html]
#20

Blex

[GLOBAL: userInfoPane.html]
Blex
  • Corona Geek

  • 1,199 posts
  • Corona SDK

Psst... @graham07, I posted the solution in a new thread you opened up today in the Newbie Questions forum. 



[TOPIC: post.html]
#21

saifuls.ctg89

[GLOBAL: userInfoPane.html]
saifuls.ctg89
  • Observer

  • 29 posts
  • Corona SDK

Psst... @graham07, I posted the solution in a new thread you opened up today in the Newbie Questions forum. 

Can you upload the link to the post cause I'm facing the same issue.



[TOPIC: post.html]
#22

yvandotet

[GLOBAL: userInfoPane.html]
yvandotet
  • Contributor

  • 184 posts
  • Corona SDK

Helo sdk tester,

 

I have the same issue : " ERROR: Tile layer encoding/compression not supported. Choose CSV or XML in map options. "

 

how did you resolve this ?



[TOPIC: post.html]
#23

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 25,471 posts
  • Enterprise

Please continue this conversation about the compression error here:

 

https://forums.coronalabs.com/topic/71281-tiled-question-encodingcompression-not-supported/

 

I'm not going to lock this thread for continued conversation about the OP's original question. But for answers to @yvandotet, please use the other feed.

 

Rob




[topic_controls]
[/topic_controls]