PhaserEditor2D / PhaserEditor2D-v3

A web-based IDE for HTML5 game development. Powered by Phaser.
https://phasereditor2d.com
MIT License
432 stars 58 forks source link

Support Tiled JSON maps #8

Closed Tilmn closed 3 years ago

Tilmn commented 6 years ago

Hi!

I successfully worked with tilemaps that are defined with a CSV file. But it does not work as expected with tilemaps whose data is in JSON format. Where the map should appear in the canvas editor only an empty rectangle with the text "Tilemap JSON" comes up.

I tried it in a new project using super_mario.json and super_mario.png from the Phaser example "Load Tilemap Json": https://phaser.io/examples/v2/loader/load-tilemap-json.

puzzud commented 6 years ago

I'm interested in the response to this issue as well.

Phaser Editor documentation states that only CSV tilemaps are supported: https://phasereditor2d.com/docs/canvas.html?highlight=csv%20tilemaps#tilemap-properties

My guess is that JSON tilemaps support is not full and is limited. In my current project, I use a mix of CSV and JSON tilemaps because I absolutely need to have some of the extra functionality and ease afforded by JSON tilemaps.

For JSON tilemaps, I just load them manually in "user code", forfeiting the benefit of seeing them in the Phaser Editor Designer.

At the moment, Phaser Editor is supporting JSON tilemaps to the extent of organizing them in a pack file and giving them keys I can refer to within code.

At a minimum, I'd like to see Phaser Editor documentation expanded to be concise about the level of JSON tilemap support, if it is going to sprinkle in some references and support within it.

Tilmn commented 6 years ago

Oh no. Me noob did not read the f** manual. I am very sorry. Thanks a lot for clearing this up, @puzzud !

So, support for tilemaps with JSON data is not yet supported. So this thread is more a feature request. Still, at least there are two users who would need it! :)

PhaserEditor2D commented 6 years ago

Hi guys, i am in a travel, sorry muy late response. I will take a look.

PhaserEditor2D commented 6 years ago

Hi @puzzud

My guess is that JSON tilemaps support is not full and is limited.

JSON Tilemaps are not supported in the scene editor (Canvas), and at the moment we do not plan to support it in Phaser Editor v1.

use a mix of CSV and JSON tilemaps because I absolutely need to have some of the extra functionality and ease afforded by JSON tilemaps.

It would be great if you explain a bit more how are you using the JSON tilemap. We think the main difference between JSON and CSV tilemaps, is that the first one supports other kind of layers like the Object Layer, where you can set certain metadata that you can parse in your game to create custom objects. However, our philosophy is that you can use CSV tilemaps to create the maps, but you can use Phaser Editor's groups and prefabs to create the "object layer".

Take a look to the example "Sunny Land Forest (pixel art, tilemap)", note there are some "object layers" like carrots_group, stars_group, propsFront and others.

puzzud commented 6 years ago

It would be great if you explain a bit more how are you using the JSON tilemap.

I'm just having Phaser Editor reference it in a Pack file so it gets preloaded; nothing more than that. I load it into a state manually.

I'm using CSV tilemaps for things like UI; which don't need to rely heavily on different layers and tile properties. Being that they are for UI, it's good to see such tilemaps in Phaser Editor Designer.

PhaserEditor2D commented 6 years ago

I'm just having Phaser Editor reference it in a Pack file so it gets preloaded; nothing more than that. I load it into a state manually.

Yes, I understand it, but my question is why are you using a JSON tilemap and not a CSV tilemap. What data do you store in the JSON tilemap that you do not store in the CSV map? Because I think that extra data that you store in a JSON tilemap can be "stored" in other Phaser Editor objects like groups and prefabs. But maybe I am wrong, for that reason, I appreciate if you explain a bit more your use-case.

puzzud commented 6 years ago

I set properties on tilemaps, tilemap layers, and tiles.

I also like to composite multiple tilemap layers; so multiple CSV files is a pain.

JSON Tilemap Object Layers versus Phaser Editor Designer object management: I like what Phaser Editor does, but if I'm using a separate utility (Tiled) to create tilemaps, I'd prefer to have object information stored in those files. I added a little extra logic that will load prefabbed sprites from JSON Tilemap objects. I assume a long term aspiration for Phaser Editor is to have it author tilemaps.

For games not using tilemaps for level data, the Canvas Design stuff is great.

I get what you are saying about using groups, prefabs, and ultimately separate canvases for levels. That's certainly an acceptable workflow. It isn't my current project's approach, but I could see using it in the future. Again, using tilemap files is a sort of slippery slope.

PhaserEditor2D commented 6 years ago

I also like to composite multiple tilemap layers; so multiple CSV files is a pain.

It is a strong argument. When I implemented the tilemap support I did my own script to extract the CSV files from the JSON format. I considered to provide a tool to do that, in Phaser Editor, but in the end, I decided to keep that energy to implement the JSON format directly.

I assume a long term aspiration for Phaser Editor is to have it author tilemaps.

Yes, I have that aspiration too, but in the meantime we should provide the better integration with the Tiled formats and workflow.

Thanks very much for your feedback!

Blue-Pilkinton-Ching commented 5 years ago

Hi There! I was having a problem where I couldn't add a JSON tilemap to Phaser Editor. I just saw this post, and I was wondering if it was still the case for Phaser Editor V2. (Phaser 3) I think I have done everything right, I've got the tilemap, tileset all in a pack and that's being loaded, the tileset works fine, but I can't add my tilemap to the scenefile and it doesn't apear in the "blocks" tab.

EDIT I'm a little bit confused because it seems to work for the sunnyland woods example project.

PhaserEditor2D commented 5 years ago

Hi @BluePC1, yes, we should add tilemap support to v2 of the editor (Phaser 3), but it will take some time, right now we are working on the documentation.

Please, read this article about how we added a tilemap in the sunnyland woods examples:

https://phasereditor2d.com/blog/2019/03/commenting-the-sunny-land-woods-demo-tutorial

The main idea is that we use a "fake image" as reference and a custom Phaser factory. If you have any doubt please write a comment in the article.

PhaserEditor2D commented 4 years ago

JSON tilemaps are not going to be implemented in v2. We transfer this to the next web-based editor.

PhaserEditor2D commented 3 years ago

Done in v3.8.0.