-
-
Notifications
You must be signed in to change notification settings - Fork 643
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support JSON format maps #140
Comments
…de less "xml" specific JSON file will be preloaded now if the extension is changed to 'json" in the resource file, but won't be parsed later during level loading. Quick Wish list : * make the me.TMXParser more OO and Generic * add (fake) JSON parsing to te TMXParser
This would definitely be a good feature for the framework. I would really like to help in the implementation of it, but all these TMX and Tiled classes are so messed up and undocumented that I can't understand anything. I guess new classes for parsing JSON maps need to be created. Can you guys give us more light into the tree of this classes, what each one is doing and what needs to be done/refactored? |
yep, that's definitely something i'm looking forward to as well for the next 0.9.6 version ! now in order to understand the current implementation :
then, in terms of addiing support for JSON, my idea was more to work around the TMXParser : today it only support XML files, but adding the JSON format to it would allow make this completely abstract from the rest of the code, as they would only request for a specific attributes and corresponding value, wihtout having to care about the format itself. I beleive that this is a way better approach, instead of rewriting the whole thing. |
…d related inheritance and additionally, it also clarifies the documentation, and should help with ticket #140
Awesome news : http://blog.ludei.com/ |
That's great, but I still think it is really good for adding support for JSON format. I'll try adding it some in the future when I find time. For me it feels wrong to use XML in javascript when you can do it with JSON 😆 |
@nvlbg personnaly I like to use XML, as during the level design phase it allows to easily test any changes just by doing a CTRL+S in Tiled and F5 in the browser. JSON could however be used when deploying the game for the here above listed benefits. |
@obiot et al. It deserves mention here, but exporting JSON is just as easy in Tiled; CTRL+E. ;) |
A few limitations I'm noticing :
|
amazing, I'm running right now the platformer example on my iphone using cocoonjs ! which means JSON parsing is done ! well it might still requires some code cleaning and deep testing to ensure nothing is missing, but so far so good ;) I'll merge branches a bit later, and i'm so happy about it ! ;) |
WOOOOOO!!!! That's awesome news. How is the performance on CocoonJS compared to Safari? (Not sure you'll be able to tell right away with the platform demo, but thought I would ask!) I'll do a quick code review for you tonight before sleep! |
for the performances, so far i'd say the same, but since all my demos are currently keyboard based games, i don't really have anything to really try it for now ... that would be good for the code review, and that makes me think that I commented the polygon support in JSON :) |
Feature request for Tiled to support exporting JSON-format tilesets (TSX): mapeditor/tiled#381 |
Done with quick review! :D Good work, I like what I saw. I will give it some testing tomorrow maybe. |
thanks! honestly it was not an easy task, and there is still some code that can be optimized (not to mention the weird stuff you saw that need fixing). I'll keep testing it this evening and eventually merge it if I feel happy about it :) |
Ticket #140 : support JSON map formats
Branch 140 merged ! Current limitations :
Todo/known issues :
|
except from the two above limitations, JSON parsing should be complete now :) |
Closing the ticket, as everything seems to be working flawlessly :) |
It looks like Tiled supports exporting TMX to JSON since forever. We should really take advantage of this!
Also, it would be great to switch to JSON format "by default", because it won't require an XML parser. That means loading maps will be faster when using JSON. Also, CocoonJS doesn't support XML parsing. See: https://groups.google.com/d/msg/melonjs/VfXZ5LzTtzQ/B4LZ8_3Uc-cJ
The only problem I see with using JSON format maps by default is the file size. But maybe that's not really an important issue. The JSON output in Tiled is "readable" by adding a bunch of unnecessary whitespace. When I stripped the whitespace from my test map, the resulting file was actually SMALLER than the XML with Base64:
-rw-r--r-- 1 parasyte staff 7143 Nov 11 13:15 farm.json
-rw-r--r-- 1 parasyte staff 3386 Oct 14 14:54 farm.tmx
-rw-r--r-- 1 parasyte staff 2844 Nov 11 13:26 farm2.json
-rw-r--r-- 1 parasyte staff 3260 Nov 11 13:31 farm2.tmx
"farm.json" is the original output from Tiled. "farm2.json" is the same file with unnecessary whitespace stripped. And "farm2.tmx" is the same as "farm.tmx" but with unnecessary whitespace stripped. JSON is the clear winner!
We could always recommend a "build step" in the tutorial/FAQ/documentation that strips whitespace from the JSON files. There are other important savings that could be had with concatenating source files and minifying, as well.
The text was updated successfully, but these errors were encountered: