IPhone Cocos 2D Novice Note one

Source: Internet
Author: User
Tags addchild

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.