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

Handling of relative paths in TMX conflicts with Tiled #280

Open
nelsonxb opened this issue Nov 18, 2016 · 4 comments
Open

Handling of relative paths in TMX conflicts with Tiled #280

nelsonxb opened this issue Nov 18, 2016 · 4 comments
Labels

Comments

@nelsonxb
Copy link

The current version of Tiled (0.17.1) only supports relative resource paths (e.g. to tileset images) in the same directory as the map file itself. When Cocos tries to load these resources, however, it passes the resource path directly to the Pyglet resource loader, which then fails to find the resource (if your map isn't directly on the resource path). I'm currently using a workaround involving manipulating the Pyglet resource path (which IMO is an ugly way to do things).

Ideally, Tiled would have better handling of relative paths. Failing that, I believe Cocos should load resources relative to the map file.

As this would probably be considered a breaking change, it should perhaps be enabled via a parameter on the load function.

@nelsonxb
Copy link
Author

I volunteer to work on this, if it isn't objected to or otherwise resolved by the time I get around to it.

@ccanepa
Copy link
Contributor

ccanepa commented Nov 18, 2016

Sounds as a good feature, and I will be glad to merge if you implement it.
I would suggest to begin by writing an example layout and data (.tmx and resources) that your code will support.

@dangillet
Copy link
Contributor

Hello,

I'm probably missing the issue here... If I take test/test_plarformer.py and I remove lines 14-15, the script still works. And it works because when cocos tries to load the resource here it's looking if the given filename is an absolute one, then it's looking if it's a relative one and finally it tries to find it in pyglet.resource.
So what is your use case when this fails?

Sorry for not seeing the obvious.

@nelsonxb
Copy link
Author

nelsonxb commented Nov 19, 2016

Example is SourceComb/game-off-2016 - the maps are stored under asset/map, which is not on pyglet.resource.path (ideally). The resources are specified in the TMX relative to said file, but they won't be found unless the pyglet.resource.path includes asset/map.

If you wanna see it in practice, for now try cloning that repository and modifying game.tiles.load_map. When I get around to working on this properly I'll include an example use case.

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

No branches or pull requests

3 participants