使用CCSpriteBatchNode时,所使用的贴图必须是同一张图片,意思是
CCSpriteBatchNode* batchNode = CCSpriteBatchNode::create("t.png");
里面的“t.png"要和
batchNode->addChild(picture)
里的picture是同一张图片,同一张图片意味着batchNode->getTexture()->getName() == picture->getTexture()->getName()
CCSpriteBatchNode的使用时有两种方式:
1、按照
http://www.cocos2dev.com/?p=331中的方式, 即完全用同一张图片
2、如果要显示不同的图片呢?可以用TexturePacker将不同的图片制作成一张图集,然后
这样,就batchNode->getTexture()->getName() == close->getTexture()->getName()了CCSpriteFrameCache *cache = CCSpriteFrameCache::sharedSpriteFrameCache();
cache->addSpriteFramesWithFile("t.plist","t.png");CCSpriteBatchNode* batchNode = CCSpriteBatchNode::create("t.png");
addChild(batchNode);
CCSprite* close = CCSprite::spriteWithSpriteFrameName("CloseNormal.png");batchNode->addChild(close);
这个时候如果这样写:CCTexture* texture = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("CloseNormal.png")->getTexture();
这个texture其实是t.png的texture.