Use tiled to create a cocosd-x Map

Source: Internet
Author: User

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 ;}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.