1. Create a wizard from the file:
Ccsprite s = [Ccsprite spritewithfile:@ "Pic.png"];
[s SETPOSITION:CCP (20,20)];//Note that this is the Cartesian coordinates, starting from the lower left corner
S.anchorpoint = CCP (0.5f,0);//anchorpoint can be understood as a fixed point of white paper
[s.setscale:1.5f];
[Self.addchild:s z:2 Tag: "Demo"];
2. Sprite frame, loading spritesheets:
[[Ccspriteframecache Sharespriteframecache] addspriteframewithfile:@ "pic.plist"];//read the source code can be seen, most of it is the resolution plist frame, Meta will be stored in a dictionary.
Ccsprite s = [Ccsprite spritewithspriteframename:@ "Pic.png"];//pic.png to correspond to the real name field in Pic.plist.
3. Batch wizard, improve the performance of the method:
Ccspritebatchnode *SBN = [Ccspritebatchnode batchnodewithfile:@ "Sbn.png" capacity:10];
[SELF.ADDCHILD:SBN];
for (int x = 0; x < 10;x++) {
Ccsprite s = [Ccsprite spritewithbatchnode:sbn rect:cgrectmake (0,0,64,64)];
[SBN Addchild:s]
}
This article from "Do not know when will leave" blog, declined reprint!
IPhone Cocos 2D Novice Note one