"Running and Running" (v)--adding obstacles to the use of tiled barrier layers

Source: Internet
Author: User

"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

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.