Skip to content
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

Add support for TSX tilesets #429

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Bushstar
Copy link
Contributor

Workaround to support Tiles TSX tilesets files. When a TSX file extension is encountered in read_from that file will be read from the path and the bytes ignored.

Bevy gives a byte stream to the TMX file, when Tiled comes across a TSX dependency from that file it will try and read it from the same stream which results in the same TMX file being read. The Tiled crate does not yet support loading child dependencies separately.

Some discussion where I initially queried this as a bug, it was mentioned that Tiled may at some point be updated with Bevy in mind, until then we have this workaround. Works locally and I can access custom tile properties from the TSX tileset.

mapeditor/rs-tiled#265 (comment)

@NHodgesVFX
Copy link

One thing I noticed when trying to load a tsx was the image path that the tsx referenced was being doubled up on

For example

In the assets directory the tileset image is saved as "maps/demo/TestTileTest.png" however, when loading, it attempts to load it from /maps/demo/maps/demo/TestTileTest.png resulting in the warning

WARN bevy_asset::asset_server: encountered an error while reading an asset: path not found: this causes the map to not be loaded.

The cause is on line 159 let tile_path = tmx_dir.join(&img.source); &img.source already contains the correct path so the join here causes the doubling up. Removing join call solves this issue.

I am quite new to bevy so not sure if removing the join call will have unintended consequences but for the one map I loaded it seems to work fine.

@StarArawn
Copy link
Owner

I have no interest in merging in new features to the tiled asset loader. My reasoning is that its outside of the scope of what this project is. The tiled examples primary function is only meant to be an example on how you could load in tiled data. Which is why its located in the example folder and not part of the crate itself. I'm more than happy to work with someone on creating a bevy_tiled crate. 👍

@stevepryde
Copy link
Contributor

fyi I started a new crate and applied this PR to it.
https://github.com/stevepryde/bevy_ecs_tiled

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants