TMX Generator

For my game I need to output TMX files. There is an extension available for cocos2d-iphone called TMXGenerator (https://github.com/cocos2d/cocos2d-iphone-extensions/tree/master/Extensions/TMXGenerator).

Unfortunately I haven’t found anything for C*+ yet, so I’m going to convert the cocos2d-iphone version to c*+. Then maybe add it to the cocos2d-x extensions (https://github.com/cocos2d/cocos2d-x-extensions/tree/master/extensions).

I’ve just finished the first version of the TMXGenerator. The code can be downloaded from https://github.com/rohinnz/COCOS2D-X-TMXGenerator

It’s really easy to use. You just parse through an instance of a CCTMXTiledMap and it returns a std string with the xml, which you can then save as a TMX file or store in a database.

Please let me know if you find any bugs. I’m hoping this will be useful for those who want to include a level editor in their games.

sorry for my ignorance, but whats the idea behind this? to allow the player to design its own maps? or to create level editors?

Yeah basically if you ever have any reason to save a TMX map during your game. Could be you want to include a level editor or you want to save the players changes during gameplay if it’s a sandbox type game.

hey, that’s great, thanks for sharing the code, btw, is there any good parser to read TMX files? this code only writes them or also parses them?

thanks

btw, how are you doing in the middle earth? (sorry for the bad joke, I could not resist :-))

I have found this: http://code.google.com/p/tmx-parser/ maybe you use it?

Haha, yeah I hear that joke a lot!

My code only exports, as there is already a parser included in cocos2d-x for reading and rendering TMX files.

Rohin Knight wrote:

Haha, yeah I hear that joke a lot!
>
My code only exports, as there is already a parser included in cocos2d-x for reading and rendering TMX files.

mmm, I didnt know that, what’s the class to parse tmx files in cocos2dx?

Check out http://www.cocos2d-x.org/reference/native-cpp/da/d68/classcocos2d_1_1_c_c_t_m_x_tiled_map.html

Sometimes cocos2dx surprises me, is even better than one might expect :slight_smile: thanks again

TMX generator: https://github.com/alphaonex86/CatchChallenger/tree/master/tools/map-procedural-generation-terrain from CatchChallenger