新版的TileMap工具已经支持中文了,初次使用容易在对象层和对象层中单个对象的命名中采用中文,很容易报以下莫名错误
需要注意在TileMap工具中新添加对象层及图层时,最好用英文来命名,可以参考以下重点红色部分:
01 /* 加载对象层 */ |
02 | CCTMXObjectGroup* objGroup = map->objectGroupNamed( "objects" ); |
03 | |
04 | /* 加载玩家坐标对象 */ |
05 | CCDictionary* playerPointDic = objGroup->objectNamed( "PlayerPoint" ); |
06 | int x = playerPointDic->valueForKey("x")->intValue();
|
07 | int y = playerPointDic->valueForKey("y")->intValue();
|
08 | |
09 | /* -------------- 加载玩家 --------------- */ |
11 | CCSprite* playerSprite = CCSprite::create( "player1.png" ); |
12 | playerSprite->setPosition(ccp(playerX, playerY)); |