Rohin
April 23, 2013, 12:17am
#1
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 ).
Rohin
April 25, 2013, 4:02am
#2
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?
Rohin
April 25, 2013, 9:26pm
#4
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?
Rohin
April 26, 2013, 8:24am
#7
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?
Rohin
April 26, 2013, 9:22am
#9
Sometimes cocos2dx surprises me, is even better than one might expect thanks again