Summary of cocos2d-x errors (Continuous updates)

Source: Internet
Author: User

Record all kinds of problems encountered on the road to learning cocos2d-x and their solutions. Continuous updates.

I. assertion TMX: Only 1 tileset per layer is supported crash:

This error occurs when I use tiledmap. The edited map in tiledmap uses multiple graph blocks on the same layer.

When a map is loaded, the assertion failure window is displayed, and the location where the map is destroyed is tracked:

CCAssert( m_uMaxGID >= m_pTileSet->m_uFirstGid &&    m_uMinGID >= m_pTileSet->m_uFirstGid, "TMX: Only 1 tileset per layer is supported");

From the prompts in the assertion, we can see that only one graph block set is supported on one layer.
That is to say, each layer in the editor can only use the graph blocks in one graph block set, rather than those in other graph blocks!

Solution: (1) Draw multiple graph blocks on the same graph block for use. (2) discard other blocks and use a specific block.


Ii. tileGIDAt:

We use tileGIDAt to obtain the ID of a graph block corresponding to a certain cell on a layer. What is GID? It can be understood as a globally unique ID, and there may be multiple graph block sets. Therefore, the ID of each graph block is not from the graph block set 1, 2, 3... This is followed by the last ID of the previous graph block set!

Therefore, to obtain the correct ID, we should:

cocos2d::CCTMXLayer *towerLayer = map->layerNamed("tower");cocos2d::CCTMXTilesetInfo *towerSet = towerLayer->getTileSet();int nGid = towerLayer->tileGIDAt(ccp(0, 0)) - towerSet->m_uFirstGid;if(nGid >= 0){}

First, obtain the first ID of the graph block set corresponding to this layer, and then subtract to obtain the correct ID.



On the way to learning, I will share with you.

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.