for a new game i am currently working on, I decided to use the cocos2dx library in combination with the tiled level editor. After writing several 2d engines from scratch I decided that it is just too much work to get it really really right (especially with a this cool features, that modern games must have) and that I actually wanted to start making a game. The library its just awesome and was currently released as version 1.0.
One thing I found out yesterday that there was no support for flipped tiles when exporting a map from the Tiled Map Editor. I think that this was a big shame and digger into the source codes of both, Cocos2dx and Tiled to find out the right way to to implement it. You can get the final result here:
It was actually pretty easy. Tiled Editor stores all maps in TXML format which is actually a dialect of the XML format. When saved uncompressed, you can see that maps are stored like this:
<layer name=”Tile Layer 1″ width=”5″ height=”5″>
In this example, the tile vids with 1 and 2 are the original tiles 1 and 2 unflipped. This high integer values are the tile values for flipped tiles.
I found out, that the guy who implemented flipping in the Tiled Editor uses two bit flags to check wether a tile is flipped or not.
Horizontally Flipped = 0×80000000
Vertically Flipped = 0×400000000
So in order to determine if a tile is flipped we just have to check against these two flags and than clear the gid. Pretty easy
To use it, download the two source files and replace them with those in you current cocos2dx library. It will work out of the box (supposed that you don’t have made any changes on your own)
The only affected cocos2dx method is CCTXMLLayer::appendTileForGid( … )
It is a very basic implementation until now and supports the flipping of tiles at the parsing stage. If you want to change or add tiles at runtime you are on your own But I believe most of us won’t do it.
Hint 1: Using flipped tiles reduces the size of your tile set dramatically and allows for more proper level design.
Hint 2: Press ‘x’ or ‘y’ to flip on the respective axles.
Pictures of my new game:
First of all: HAPPY NEW YEAR !!!!
The RPG project was a little bit quiet the last three months, but that didn’t mean that we were not working on it. The team has grown to four people and consists now of a Game Designer, an American who lives in Beijing and works there at a Chinese Game Company, a Swedish composer, who is so god damn talented that it scares me, a 2D Pixel artist from Amsterdam with an incredible talent for character design and last but not least… me, the nerdy programmer and some how manager of this all. Together we will work hard in 2012 to realize our project.
The goal for the next year is to design all the necessary production tools to develop and further to create a 2 hour long game which introduces the player to the world and the main characters. After that we will try to find a publisher! So, if you know one, let me know
We have awesome ideas in our design paper right now and I can tell you, this RPG is about to become great. It will be an awful lot of work but we love what we do and that is what drives us forward.
So lets hope the world will remain after 21.12.2012 ^^