Small man (Bill man) Personal Original, welcome to reprint, reprint please indicate the address, small man (Bill man) column address http://blog.csdn.net/bill_man
There is also an important element in the game, namely the genie class. We can generate the genie through a single picture or a texture set. The use of the genie class is flexible, and the batch processing method of the genie helps us create multiple Genie and save rendering efficiency.
Use of the genie class
The preceding example uses a part of an image to create a Sprite class and add it to the scenario. The first parameter is the image path, and the second parameter is the rectangle from which the image is divided.
1. Batch Processing of genie
When you need to display two or more identical genie, If you render the genie one by one, your frame rate will be reduced by at least 15%. You can use ccspritebatchnode to batch process these genie so as to avoid the decrease in Frame Rate and use it as the parent layer (similar to layer) to create a child genie, which can improve the program efficiency, let's first take a look at the API
There are two methods to create ccspritebatchnode. The difference is mainly in the second parameter. The first parameter is the texture set path, and the other parameter is the number of subnodes. Of course, if you use the first method to not explicitly define the number of subnodes, the system will use the default value 29. If the space is exceeded during running, the system will increase the capacity by 33%. The method used is described as follows.
First, define it, as described in the API, and then add it to the scene.
When adding the genie, you only need to use the label to get the ccspritebatchnode, then create the genie through the ccspritebatchnode texture, and add the genie as a subnode to ccspritebatchnode.
However, there is a limit for using ccspritebatchnode, that is, the image used must come from the same file. If you use an image to create an genie, you cannot specify the depth of the genie, all the genie must be in the same paintlayer, but you can use a texture set to avoid this problem. If all your textures are in the same file, you only need to create a ccspritebatchnode. The texture size must be equal to the Npower of 2. You can use zwoptex to create textures. This is a paid software. It is not difficult for me to write a similar tile software through Java or C #. You can try it.
2. Set the anchor
You can set the anchorpoint through setanchorpoint, (0, 0) to the lower left, (0.5, 0.5) to the center, () to the upper right, and so on.
I just started to study this engine. If there are any errors, I hope you can correct them more.
The next article describes how to use animations.