i want to render a sprite on each tile of a 96X96 tilemap.
i want to use spriteBatchNode to get a high framerate and low memory allocation.
the high framerate is easy to achieve, but the memory allocation is much more than using a same size tilemap.
i don’t know where the problem is.
here is my code
CCTexture2D *texture = NULL;
texture = CCTextureCache::sharedTextureCache()->addImage("black.png");
m_batchNode = CCSpriteBatchNode::batchNodeWithTexture(texture ,1000);
m_nodeBoss->addChild(m_batchNode, kMaxZOrder);
for (int i = 0; i < m_mapSize.width; i++)
{
for (int j = 0; j < m_mapSize.height; j++)
{
CCSprite* spriteBlack = CCSprite::spriteWithBatchNode(m_batchNode, CCRectMake(0, 0, 32, 16));
spriteBlack->setColor(ccc3(0,0,0));
spriteBlack->setOpacity(255);
spriteBlack->setPosition(CCUtility::positionAt(ccp(i, j)));
m_batchNode->addChild(spriteBlack);
}
}
the code above causes 10M memory and the timemap just causes about 3M