-
Notifications
You must be signed in to change notification settings - Fork 231
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
Support for external tilesets #16
Comments
We may use a Signal : when the map is loaded or is already included in the tileSets we dispatch a Signal. And then we process the map. However we have to be careful if we use multiple external tileSets. |
I've working on this, take a look on the last update : 5abd134 If we have several tilesets png and don't want to embed them, we have to load all of them before using something like LoaderMax... Hope that help! |
Ok, I updated my gist slightly https://gist.github.com/9cde603db32d1d58b8b2 I'm not sure is this a best practice, but it works for me at least :) I had to move TmxMap loading outside the constructor because otherwise it process the level before I can add a listener to it. Also my FromTiledMap takes now the whole tmx object as parameter this way I can make sure that external files are loaded before I process it. ... and this version of FromTiledMap uses TextureAtlas instead of actual images. |
We have two differents approach :) For me, we shouldn't load external tilesets into the TmxMap, but load them before and give them as an argument, like I did. I don't pretend this is the best solution, but loading directly in the TmxMap class we have to be sure to do it in a modular way so users won't have problem: e.g. offering the path as an argument (it might be on mobile, ect...). Using QuadBatch and TextureAtlas make it greatly optimized for Starling! When I've designed this exporter, I'd in mind that it should works with flash display list and Starling, so I used Bitmap which is not the most optimized solution. Maybe I should dissociate those version and create a new ObjectMakerStarling class. |
Yep. Those external tilesets will help me so much as a programmer, because I can make those tileset files separately from the levels and then just give those to level designers. I have gave up on hope to explaining how to add custom variables to tiles :D (Our level designers are not "REAL" level designers) (ce as StarlingCitrusEngine).starling.stage.addChild(qb); ... but yeh, ObjectMakerStarling sounds awesome aswell. |
Hey Ossi, I'm definitely considering your solution with tiled maps using quad batch and creating an ObjectMakerStarling class, optimized! Would you mind to provide me an example/samples using a TextureAtlas? Thanks again! |
Ok, I got it working! However do you also have a "line" between each tile? They come from the background, if you change its color, it'll change the color line. |
I've make a new build so it can be tested : http://citrusengine.com/v3-0-4-meets-the-dragon/ |
I haven't tested it yet but the line thing sounds like the problem that I had earlier. Check out this thread |
Thanks a lot, it made the trick! :) |
Nice! 👍 |
I finally had some time to test ObjectMakerStarling. It works perfectly! Tough, I still had to change FromTiledMap to take the entire tmx object as an argument, because I need to load those external tileset files. I also made TmxMap class to skip the external files as otherwise it creates an "empty" tileset from them. https://github.com/osro/Citrus-Engine/commit/7302b11d68c792d62e886cb9e7ca78eb016c4a2f |
I've never worked with external tilesets in the editor, and I don't have tsx file to test. Have you find some tsx samples? However when we parse the map, we should have information on the external tile sets right? |
Yep, the main problem is that as the current ObjectMakers will create the TmxMap object and I don't have a way to add those tilesets before it process the objects. In the Tiled editor you can export any tileset you have made to an external file. And then you can import that file to other maps from menu (Map > Add External tileset) The tileset file is XML file that is in the same format as it would be inside the TMX file. Here is an example from one of my files <?xml version="1.0" encoding="UTF-8"?>
<tileset name="tilset" tilewidth="32" tileheight="32">
<image source="../../../assets/images/tileset.png" width="64" height="128"/>
<tile id="0">
<properties>
<property name="name" value="ground4"/>
</properties>
</tile>
<tile id="1">
<properties>
<property name="name" value="ground3"/>
</properties>
</tile>
<tile id="2">
<properties>
<property name="name" value="ground2"/>
</properties>
</tile>
<tile id="3">
<properties>
<property name="name" value="ground1"/>
</properties>
</tile>
<tile id="4">
<properties>
<property name="name" value="brick1"/>
</properties>
</tile>
</tileset> |
Ok, I've be able to test quickly! That's cool, it exports the properties that we defined. Then if we add our tsx as an external tile, we can't see properties. However using the button on the left import the tilesets and then we can access properties. Finally, it isn't what we need ? |
There is some technical limitation once you have exported your tileset. |
Yes indeed, but finally we can do it easily. The problem with ObjectMaker is to make it as generic as possible. And finally if we can use simple tricks to do it, that's perfect! |
I mean, finally we just need to press the import button on our external tsx file and then it will be ok via the ObjectMaker. There is a problem using this method? |
Nope, the tmx file will point to the external file <?xml version="1.0" encoding="UTF-8"?>
<map version="1.0" orientation="orthogonal" width="60" height="40" tilewidth="32" tileheight="32">
<tileset firstgid="1" source="tileset.tsx"/>
<layer name="Tile Layer 1" width="60" height="40">
... etc |
I've make some test : indeed you have this "code" if the tileset is external, but then if you import it, it is no more external. <tileset firstgid="121" source="../../../../../../Desktop/tiles.tsx"/>
<layer name="background" width="20" height="10"> after import : <tileset firstgid="121" name="tiles" tilewidth="64" tileheight="64">
<image source="Genetica-tiles.png" trans="ff00ff" ... And it works fine with the actual ObjectMaker |
Yep, but then I lose the point why it's external file :D What I have done is that I have one "template.tmx" file where I manage my external tilesets. |
Hmm ok, I understand :) |
Now that the ObjectMakerStarling enables the AssetManager as an argument, there shouldn't be anymore issues. |
https://gist.github.com/9cde603db32d1d58b8b2
I've tried to add a support for external Tileset files in Tiled maps.
Loading part works fine, but the problem is that ObjectMaker2D will process the map file before these asynchronous loader events occurs.
Any suggestions how this could be solved?
The text was updated successfully, but these errors were encountered: