// 图层
bool HelloWorld::init()
{
if ( !CCLayer::init() )
{
return false;
}
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
CCTMXTiledMap *map = CCTMXTiledMap::create("map1.tmx");
this->addChild(map);
CCSize mapSize = map->getMapSize();
CCSize tilesSize = map->getTileSize();
CCLOG("mapSize:%f_%f, tilesSize:%f_%f", mapSize.width, mapSize.height, tilesSize.width, tilesSize.height);
CCArray *pChildArray = map->getChildren();
CCSpriteBatchNode *child = NULL;
CCObject *pObject = NULL;
// 遍历每个图块,并且设置抗锯齿
CCARRAY_FOREACH(pChildArray, pObject)
{
child = (CCSpriteBatchNode *)pObject;
if (!child)
{
break;
}
else
{
child->getTexture()->setAntiAliasTexParameters();
}
}
// 取出图层中的最后一个图块进行操作
CCTMXLayer *layer = map->layerNamed("layer1");
CCSprite *pSpr = layer->tileAt(ccp(9, 9));
pSpr->setScale(1);
pSpr->setRotation(-90);
return true;
}