phaser icon indicating copy to clipboard operation
phaser copied to clipboard

Tiled 1.9 support

Open TorbenTK opened this issue 1 year ago • 4 comments

Changelog of Tiled (25th of June 2022): https://doc.mapeditor.org/en/stable/reference/tmx-changelog/#tiled-1-9

Tiled had a 1.9 release which changes a few things, most notably:

  • type has been renamed to class in tile and object (Phaser.Types.Tilemaps.TiledObject)
  • class has been added to a variety of types
  • New properties for tile and tileset (Phaser.Tilemaps.Tile and Phaser.Tilemaps.Tileset)

Adding those new properties should be sufficient, given most of the code only translates the .json to objects and it's up to the developer from there to call the correct properties. This should also ensure backward compatibility with Tiled < 1.8 as I suspect plenty of people are still using it.

Example with filtering data

The following works with Tiled 1.8 (objects: Phaser.Types.Tilemaps.TiledObject in ObjectLayer):

const doors = this.map.getObjectLayer('Areas').objects.filter((zone) => zone.type === 'Door');

Tiled 1.9 expects:

const doors = this.map.getObjectLayer('Areas').objects.filter((zone) => zone.class === 'Door');

TorbenTK avatar Jul 20 '22 11:07 TorbenTK

@TorbenTK Simple temp workaround solution found in the release notes of 1.9.x : https://www.mapeditor.org/2022/06/25/tiled-1-9-released.html

In addition, the “Type” property previously available only for objects and tiles is now available for all data types as the new “Class” property. For consistency, this value is written out as “class” also for objects and tiles, but a project-wide compatibility option is provided to make it still write out as “type”:

image

And to make reachable in Phaser you also need to enable this in preferences of Tiled:

image

Just tested and it's work and let you go use "type" rather than "class"

buzzjeux avatar Nov 27 '22 01:11 buzzjeux

Were there any updates in Phaser regarding 'class' property in Tiled? I'm using Tiled 1.9 because I thought someday Tiled might remove the compatibility switching to 1.8.

jhoryong avatar Aug 03 '23 01:08 jhoryong

@jhoryong Tiled 1.10 switched back to type because of compatibility breakage. I assume Phaser won't be introducing any changes to it due to this change of course.

Another reason why I believe this is because, fortunately, the solution provided by buzzjeux now applies to Tiled 1.9 users. If you are using class and must continue to do so, you can toggle the compatibility setting in Tiled, as described in Tiled 1.10's release notes:

In Tiled 1.9, the type attribute was renamed to class as part of unifying custom types, mostly for consistency reasons. This compatibility breakage continued to cause trouble months after that release, even with an option available in the Project Properties to save files using the Tiled 1.8 format. This is why this change has been reverted in Tiled 1.10. Of course, there is now a “Tiled 1.9” compatibility version for those who’s project relies solely on the class attribute.

https://www.mapeditor.org/2023/03/10/tiled-1-10-released.html

I think that setting will stick around for a while. But you can probably check with the devs themselves (https://github.com/mapeditor/tiled/issues).

TorbenTK avatar Aug 03 '23 08:08 TorbenTK

@TorbenTK Thank you for the answer. I didn't know there was Tiled 1.10 released! I should just update my Tiled. Thanks!

jhoryong avatar Aug 07 '23 05:08 jhoryong