Cocos2d-x: How to optimize memory from 100 same sprites? -
my task draw 1 sprite 100 times in frame. example need draw row made of 1 sprite "sprite.png". this:
ccsprite *spritearr[ 100 ]; ( unsigned int = 0; < 100; i++ ) { spritearr[ ] = new cocos2d::ccsprite(); spritearr[ ]->initwithfile( "sprite.png" ); spritearr[ ]->setposition( cocos2d::ccpoint( * 10, 100 ) ); this->addchild( spritearr[ ] ); }
and that's problem. allocate memory 100 times 1 sprite don't know how differently. how can optimize it? there way in cocos2d drawing sprite using coordinates (x , y) not allocate memory each same sprite?
you're good. 100 sprites reference same texture object, it's single texture in memory. each sprite instance adds less 500 bytes of memory on top of that.
your best option conserve memory use .pvr.ccz format images.
Comments
Post a Comment