melonjs / melonJS

a fresh, modern & lightweight HTML5 game engine
https://melonjs.org
MIT License
5.93k stars 643 forks source link

Use tmxData.type instead of file extension and also return a result for xml extension #1228

Closed customautosys closed 6 months ago

customautosys commented 6 months ago

Dear Olivier,

I would like to suggest this change as for those of us using a build step (React / Vue), "tsx" is usually recognised as a typescript-jsx file type which renders us unable to import an asset with that extension as it would be parsed wrongly. Therefore, I suggest to use the type attribute instead of the file extension if available. Also, if the type is XML, it should allow the user to deal with whatever was parsed rather than simply returning nothing.

obiot commented 6 months ago

it could even be simplified to result = data.map || data.tilesets[0];.

after all tsx files only defines tileset, so if map is defined its a tmx file, and if not it's automatically a tsx file.

customautosys commented 6 months ago

I just pushed a new commit https://github.com/customautosys/melonJS/commit/95eb9b7d38204a680ad8dca1a13e8964261ff495 but it's not appearing yet, I did result = data.map || data.tilesets[0] || data; so in case for some reason there is no "map" or "tilesets" it'll still return something.