TiledLib.Net icon indicating copy to clipboard operation
TiledLib.Net copied to clipboard

Support for Tiled Object Templates

Open swidku opened this issue 5 years ago • 2 comments

As far as I can tell TiledLib doesn't support Tiled Object templates. Am I missing something or has it not been implemented? When ever I try and load my map with template objects it just errors out with InvalidOperationException "There is an error in XML document". Tiled Template Docs

Thanks

swidku avatar Apr 06 '20 21:04 swidku

Unfortunately I've missed this feature when updating to the new *.tmx versions. If you'd be willing to share the tmx of your map, it would help locate the issue and ensure there aren't any other errors keeping it from parsing.

Ragath avatar Apr 07 '20 09:04 Ragath

So it looks like normal objects are stored here like normal but template objects reference a normal file. Side note: you can also add extra data onto the templated objects aswell on a per instance base.

Heres it the object layer: <objectgroup id="5" name="entity_layer"> <object id="106" gid="27" x="382" y="390.333" width="16" height="16"> <properties> <property name="entity" value="player_spawn"/> </properties> </object> <object id="120" template="TiledTemplates/chicken_entity.tx" x="656.667" y="391.333"/> <object id="121" template="TiledTemplates/crate_entity.tx" x="495.333" y="418.667"> <properties> <property name="someextra" value="extra data"/> </properties> </object> </objectgroup>

Here is a template file: <?xml version="1.0" encoding="UTF-8"?> <template> <tileset firstgid="1" source="../chicken.tsx"/> <object gid="1" width="16" height="16"> <properties> <property name="entity" value="EntityChicken"/> </properties> </object> </template>

Sorry about the formatting here is a quick formatter if you need it

swidku avatar Apr 07 '20 21:04 swidku