[Basic Objects] Tilemap

Adding A Tilemap

Drag a Tilemap from the Basic Objects section onto the middle canvas.

256

Selecting The Tilemap

You can select the Tilemap if it isn't already selected from the Animation Editor at the bottom. The Tilemap doesn't appear in the resources as it's part of the Scene or other object that you are using.

257

Changing The Tilemap

You can change the Tilemap by selecting another Tilemap from your computer. You can use the website below to create Tilemaps for free.

http://www.mapeditor.org/

354

Accessing The Timemap In Code

Timemaps can be accessed via their Name or Tag which can be set in the Properties section.

356

To access the Timemap from a scene for example, in code it is simple. You either access it as a Node or cast it to a Timemap allowing you to use Timemap methods along with Node methods.

Node *rootNode = CSLoader::createNode( "Filepath to .csb file" );
this->addChild( rootNode );

// tilemap accessed as a node using it's name
Node *tilemap = rootNode->getChildByName( "Name set in Cocos Studio" );

// tilemap cast to a tilemap using it's name
TileMapAtlas *tilemap = ( TileMapAtlas * )rootNode->getChildByName( "Name set in Cocos Studio" );

// tilemap accessed as a node using it's tag
Node *tilemap = rootNode->getChildByTag( 5 );

// tilemap cast to a tilemap using it's tag
TileMapAtlas *tilemap = ( TileMapAtlas * )rootNode->getChildByTag( 5 );
var rootNode = ccs.load( "Filepath to .json file" );
this.addChild( rootNode.node );

// get the tilemap by name
var tilemap = rootNode.node.getChildByName( "Name set in Cocos Studio" );

// get the tilemap by tag
var tilemap = rootNode.node.getChildByTag( 5 );

Note: Cocos2d-JS doesn't require casting to use Timemap methods.