标签:ted oat print play dict pretty 地图 size http
读取.tmx地图
m_GameMap = CCTMXTiledMap::create("map1.tmx");
this->addChild(m_GameMap,1);
读取对象数组
bool bFlag = false;
//获取对象层
TMXObjectGroup *group = getGameMap()->objectGroupNamed("coll");
//通过对象名获取该对象层对象
auto player = group->getObject("monst1");
//获取改对象层数组
auto coll = group->getObjects();
for (int i = 0; i < coll.size(); i++)
{
auto& obj = coll.at(i);
ValueMap& dict = obj.asValueMap();
//获取name属性
//std::string name = dict["name"].asString();
//获取x,y属性
float x = dict["x"].asFloat();
float y = dict["y"].asFloat();
//获取width,height属性
float width = dict["width"].asFloat();
float height = dict["height"].asFloat();
Rect box = Rect(x, y, width, height);
}
标签:ted oat print play dict pretty 地图 size http
原文地址:http://www.cnblogs.com/feizuzu/p/482a7c5e11ab29d0f7c95e006017f30a.html