My task is to draw one sprite 100 times in frame. For example I need to draw a row made of one sprite "sprite.png". I do it like this:
CCSprite *spriteArr[ 100 ];
for ( unsigned int i = 0; i < 100; i++ ) {
spriteArr[ i ] = new cocos2d::CCSprite();
spriteArr[ i ]->initWithFile( "sprite.png" );
spriteArr[ i ]->setPosition( cocos2d::CCPoint( i * 10, 100 ) );
this->addChild( spriteArr[ i ] );
}
And that's the problem. I allocate memory 100 times just only for one sprite but I don't know how to do it differently. How can I optimize it? Is there a way in Cocos2d for drawing a sprite using coordinates (x and y) but not to allocate memory for each same sprite?