<title>Batch Sprite Node</title> Batch Wizard nodes when used in a lot of sprites, the use of batch processing can reduce the number of rendering times, improve efficiency, of course, when the number of sprites is small, there is no need to use batch processing
BOOL t02layers :: Init (){ if (! Cclayer:: Init ()) { return false; } ccsize winsize = Ccdirector:: Shareddirector ()->getwinsize (); Ccpoint Ptcenter = CCP(WINSIZE.WIDTH/2, WINSIZE.HEIGHT/2);
/*Ccspritebatchnode is also a container, but it can only contain Ccsprite objects, and requires these sprites to come from the same texture */
Ccspritebatchnode* Batch = Ccspritebatchnode :: Create ("Closenormal.png" );addChild (batch);_batch = batch;
Ccsprite* Sprite = Ccsprite:: Createwithtexture (Batch->gettexture ());Batch->addchild (sprite);
sprite->setposition (ptcenter);
settouchenabled ( true);Settouchmode ( Kcctouchesonebyone); return true;}
BOOL t02layers :: Cctouchbegan (Cctouch* Touch, ccevent*){ ccsize winsize = Ccdirector:: Shareddirector ()->getwinsize (); for ( int i = 0; i <; i++) { Ccsprite* Sprite = Ccsprite:: Createwithtexture (_batch->gettexture ());_batch->addchild (sprite); //ccrandom_0_1()
used to generate random numbers from 0 to 1, which is a defined macro Sprite->setposition ( CCP( ccrandom_0_1() *winsize.width, ccrandom_0_1() * winsize.height)); } return true;}
Results:
If you do not use batch processing:
Three lines of numbers, the first line indicates the number of times the sprite is rendered the third line represents the number of frames in 1s, which is the number of refreshes.
From for notes (Wiz)
Batch Sprite Node