通过titled插入对象层objects:
通过矩形框画出一个矩形:
设置其属性名称为PlayerPoint:
设计一个addplayer函数代码:
<span style="font-size:18px;"> auto visibileSize=Director::sharedDirector()->getVisibleSize();//获取窗口大小 auto playerSprite=Sprite::create("run1.png"); auto mPlayer=Player::create(); mPlayer->bindSprite(playerSprite);</span><span style="font-size:18px;">//绑定精灵</span> <span style="font-size:18px;"> TMXObjectGroup* objGroup=map->objectGroupNamed("objects"); auto playerPointDic=objGroup->objectNamed("PlayerPoint"); float playerX=playerPointDic["x"].asFloat(); float playerY=playerPointDic["y"].asFloat(); mPlayer->setPosition(ccp(playerX,playerY)); map->addChild(mPlayer);</span>