1. Next tiled, Baidu, and then download it.
2. Two reference examples:
Written by Zilong Mountain ~~
Http://www.cnblogs.com/andyque/archive/2011/04/11/2012852.html
Http://www.cnblogs.com/andyque/archive/2011/05/03/2033620.html
3. Enable tiled
A. Images use online resources such as game resource files
B. File-new file;
C. Map-New Graph Block
D. Add and addClick something on the right and click the panel on the left to map the image. You can use a paint brush or a paint tank to select multiple options;
Save the layer as Background and the file as level01.tmx .()
E. Join the project
/* Load map */CCTMXTiledMap * map = CCTMXTiledMap: create ("map/level01.tmx"); this-> addChild (map ); /* Create a Player */Player * mPlayer = Player: createWithTiledMap (map );
CCSprite * mSprite; Controller * mController; CCTMXTiledMap * map; CCTMXLayer * meta;/* map layer for collision detection */CCTMXLayer * barrier;/* obstacle Layer */
Bool PLAYER: initwithtiledmap (cctmxtiledmap * map) {/* load all objects in the object Layer */cctmxobjectgroup * objgroup = map-> objectgroupnamed ("objects "); /* load the meta Layer */meta = map-> layernamed ("meta"); Meta-> setvisible (false ); /* load the obstacle Layer */barrier = map-> layernamed ("barrier "); /* load the player coordinate object */ccdictionary * playerpointdic = objgroup-> objectnamed ("playerpoint"); float playerx = playerpointdic-> valueforkey ("X")-> floatvalue (); float playery = playerpointdic-> valueforkey ("Y")-> floatvalue ();/* Save the map reference */This-> map = map; return true ;}