"Go" http://blog.csdn.net/u010778159/article/details/44036365
First use Tiledmap to add obstacles to the original map, first create two layers, called barrier and META2, the following
Check barrier, and then use the footage in the tile, draw obstacles on the map,
Well .... A lump on the map is the said obstacle.
But if you save now and rerun the project, you can see that these obstacles do not prevent the protagonist from moving forward
So you need to use the META2 layer, first load the following tile:
(named Meta2)
Right-red block, click on "Tile Properties", add the attribute colliadable in the property, and the value changes to true
Select the Meta2 object layer and then use the red squares in the meta2 tile to fill in the previously added obstructions
Then save!
Next, we modify the code
Player.h
Meta2, which is the object layer that you just created in Tilemap
The Tilecoordforposition () function converts coordinates in cocos2d to grid coordinates in TILEDMAP
Get the Meta2 object layer in Settiledmap and set it to invisible (Red Square)
Next Modify the Settagposition function to determine if the lead is accessible
Run Run (v)-- Adding obstructions, using the tiled barrier layer