How to create a tile map programmatically?

I want to create a random game map based on hexagonal tiles of a sprite map, like in this image: http://www.hexdraw.com/Images/sampleMap.jpg
What is the best practice to do so?

  • Should I use CCTMXLayer?
  • Create a view hiearchy based on many sprites?
  • Or is it possible to draw the map into a texture shape?

Is there any working example?

You can consider choosing some existing tmx files randomly, instead of generating each grid after the game starts.