Changes in some classes of cocos2d 1.0 and later versions and version 0. xx

Source: Internet
Author: User

1. itemfromstring: Target: selector: Method of ccmenuitemfont. This method has been deprecated.]
The new method is as follows:
Java code

  1. Ccmenuitem * gamesettings = [ccmenuitemfont itemwithstring: @ "set" target: Self selector: Nil];



2 cctransitionshrinkgrow and other objects, originally named after ccxxxtransition, And now changed to cctransitionxxx. For example:
Version 1.0 or later
Ccshrinkgrowtransition cctransitionshrinkgrow
Ccslideinrtransition cctransitionslideinr
Ccslideinrlransition cctransitionslideinl

3. The ccbitmapfontatlas object is useless. It is renamed as cclabelbmfont.
Usage before 1.0:
Java code

  1. Ccbitmapfontatlas * lbscore = [ccbitmapfontatlas bitmapfontatlaswithstring: @ "Time: 0" fntfile: @ "font09.fnt"];


Version 1.0 and later usage:
Java code

  1. Cclabelbmfont * lbscore = [cclabelbmfont labelwithstring: @ "Time: 0" fntfile: @ "font09.fnt"];



4. The ccspritesheet object is gone and changed to ccspritebatchnode.
Usage before 1.0:
Java code

  1. Ccspritesheet * Mgr = [ccspritesheet spritesheetwithfile: @ "flight.png" Capacity: 5];


Version 1.0 and later usage:
Java code

  1. Ccspritebatchnode * Mgr = [ccspritebatchnode batchnodewithfile: @ "flight.png" Capacity: 5];



5. The animationwithname method of ccanimation has been deprecated and changed to animationwithspriteframes.
Original usage:
Java code

  1. Ccanimation * animation = [ccanimation animationwithname: @ "flight" Delay: 0.2f];


Version 1.0 and later usage:
Java code

  1. Cctexture2d * texture = [[cctexturecache sharedtexturecache] addimage: @ "flight.png"];
  2. Ccspriteframe * frame = [ccspriteframe framewithtexture: texture rect: cgrectmake (0, 0, texture. contentsize. Width, texture. contentsize. Height)];
  3. Nsarray * array = [[nsarray alloc] initwithobjects: frame, nil];
  4. Ccanimation * animation = [ccanimation animationwithspriteframes: array delay: 0.2f];




Version update problems:
An error, such as the title, occurred during compilation.

Java code
  1. + (ID) layerwithcolor :( cccolor4b) color
  2. {
  3. Return [[[self alloc] initwithcolor: Color] autorelease];
  4. }



At the beginning, it was a search error. I found a lot of solutions in English, including the famous Tom overflow forum, but there was no result. Later I saw the results from my friends on this forum, I think it's a matter of siblings.

11l Great God provides a solution

Add (colorlayer *) before [self alloc] as follows:

Java code
  1. + (ID) layerwithcolor :( cccolor4b) color
  2. {
  3. Return [[(colorlayer *) [self alloc] initwithcolor: Color] autorelease];
  4. }


In the new version of cocos2d, The colorlayer is updated to cccolorlayer or cclayercolor. The two are the same.

Reprinted from: http://lizi07.iteye.com/blog/1517652

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.