flame-engine / tiled.dart

A Dart Tiled library. Parse your TMX files into useful representations. Compatible with Flame.
https://flame-engine.org/
MIT License
50 stars 30 forks source link

fix: template not parsed #59

Open trunghq3101 opened 1 year ago

trunghq3101 commented 1 year ago

Description

Currently, template is parsed from a child node like this:

final template = parser.getSingleChildOrNullAs('template', Template.parse);

But according to the current Tiled format, template is not a child node anymore:

  <object id="31" template="card.tx" name="bank" gid="0" x="-256" y="736" rotation="0"/>

There is no place to load the template file as well. So, it is never found, that's why the template field in a parsed TiledObject is always null. I believe it's related to the issue https://github.com/flame-engine/tiled.dart/issues/47.

The object id is also not required anymore:

<?xml version="1.0" encoding="UTF-8"?>
<template>
 <object width="288" height="416"/>
</template>

Checklist

Breaking Change

Related Issues

Fixes #47

kurtome commented 1 year ago

But according to the current Tiled format, template is not a child node anymore

Can you clarify what docs and when this changed? If it changed relatively recently we may want to check for the template xml the old way, and then if it's not there, check the new way. That would support both versions of Tiled. I would also add inline comments that link to the relevant Tiled docs and version changes

spydon commented 1 year ago

@trunghq3101 any update on this?

trunghq3101 commented 1 year ago

@trunghq3101 any update on this?

I'm gonna continue working on this. I'm kinda being distracted by working on my game lately.

trunghq3101 commented 1 year ago

But according to the current Tiled format, template is not a child node anymore

Can you clarify what docs and when this changed? If it changed relatively recently we may want to check for the template xml the old way, and then if it's not there, check the new way. That would support both versions of Tiled. I would also add inline comments that link to the relevant Tiled docs and version changes

According to this change log, template has been just a field of an object since day one. I didn't take a look at this when creating this PR. Is the any chance that our parser has never actually worked?

spydon commented 10 months ago

According to this change log, template has been just a field of an object since day one. I didn't take a look at this when creating this PR. Is the any chance that our parser has never actually worked?

Sorry for the extremely late reply, it should be pretty simple to verify that with a small test, right?