天天看點

cocos2dx進階學習之CCTMXLayer

繼承關系

CCTMXLayer -> CCSpriteBatchNode

CCTMXLayer是在瓦片地圖中,抽象一個層的類,它繼承自CCSpriteBatchNode,也就是說它抽象了一批相同圖檔的精靈,在瓦片地圖中,用層來抽象她們。

成員函數

CCSprite* tileAt(const CCPoint& tileCoordinate);

擷取該坐标的精靈,這裡的坐标是網格坐标

unsigned int  tileGIDAt(const CCPoint& tileCoordinate);

擷取該網格坐标的GID

void setTileGID(unsigned int gid, const CCPoint& tileCoordinate);

void setTileGID(unsigned int gid, const CCPoint& tileCoordinate, ccTMXTileFlags flags);

設定該點的GID

void removeTileAt(const CCPoint& tileCoordinate);

删除tile

CCPoint positionAt(const CCPoint& tileCoordinate);

坐标轉化

CCString *propertyNamed(const char *propertyName);

屬性值

void setupTiles();

建立瓦片

virtual void addChild(CCNode * child, int zOrder, int tag);

這個接口在Layer裡不支援,在這裡重載是為了報錯

void removeChild(CCNode* child, bool cleanup);

删除子對象

inline const char* getLayerName(){ return m_sLayerName.c_str(); }

inline void setLayerName(const char *layerName){ m_sLayerName = layerName; }

總結