cocos2dx进阶学习之CCTMXLayer
繼承關(guān)系
CCTMXLayer -> CCSpriteBatchNode
CCTMXLayer是在瓦片地圖中,抽象一個(gè)層的類,它繼承自CCSpriteBatchNode,也就是說它抽象了一批相同圖片的精靈,在瓦片地圖中,用層來抽象她們。
成員函數(shù)
CCSprite* tileAt(const CCPoint& tileCoordinate);
獲取該坐標(biāo)的精靈,這里的坐標(biāo)是網(wǎng)格坐標(biāo)
unsigned int? tileGIDAt(const CCPoint& tileCoordinate);
獲取該網(wǎng)格坐標(biāo)的GID
void setTileGID(unsigned int gid, const CCPoint& tileCoordinate);
void setTileGID(unsigned int gid, const CCPoint& tileCoordinate, ccTMXTileFlags flags);
設(shè)置該點(diǎn)的GID
void removeTileAt(const CCPoint& tileCoordinate);
刪除tile
CCPoint positionAt(const CCPoint& tileCoordinate);
坐標(biāo)轉(zhuǎn)化
CCString *propertyNamed(const char *propertyName);
屬性值
void setupTiles();
創(chuàng)建瓦片
virtual void addChild(CCNode * child, int zOrder, int tag);
這個(gè)接口在Layer里不支持,在這里重載是為了報(bào)錯(cuò)
void removeChild(CCNode* child, bool cleanup);
刪除子對(duì)象
inline const char* getLayerName(){ return m_sLayerName.c_str(); }
inline void setLayerName(const char *layerName){ m_sLayerName = layerName; }
設(shè)置和獲取Layer名字
總結(jié)
CCTMXLayer是CCSpriteBatchNode的派生類,所以也是一個(gè)批精靈。瓦片地圖將其分成一層層的原因也是為了提高渲染的效率。
轉(zhuǎn)載于:https://www.cnblogs.com/niulanshan/p/6175005.html
總結(jié)
以上是生活随笔為你收集整理的cocos2dx进阶学习之CCTMXLayer的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: xenserver PXE安装系统错误的
- 下一篇: 高考成绩查询接口(转)