I'm hoping to create about 50-80 'balls' on the screen and each ball is an object of a class extending CCNode. Each ball will be about 20 x 20px
.
Would it be more efficient to
void draw()
and use ccDrawCircle()
Most effective way to draw multiple nodes, that use single material (texture) is CCSpriteBatchNode
.
// we create base bach node with texture
CCSpriteBatchNode *batch = CCSpriteBatchNode::create(textureFile, 50 /* initial capacity of node */);
// then we create our sprites with the same texture
CCSprite::sprite = CCSprite::create(textureFile);
batch->addChild(sprite);
CCSpriteBatchNode
can contain only CCSprite
s with the same texture, that used for batch node, but all sprites are drawed in single function call (batch drawing).
Color and opacity of every sprite can be changed. To colorize sprites you can create white-colored texture of ball. When you use setColor
method, white color will be transformed to color, that specified in setColor