cocos2d 1.0及以上版本与0.xx版本某些类的变化

1  CCMenuItemFont的itemFromString: target: selector:方法,该方法已被deprecated。]  
新方法使用如下: 
Java代码   收藏代码
  1. CCMenuItem *GameSettings = [CCMenuItemFont itemWithString:@"设置" target:self selector:nil];  


2  CCTransitionShrinkGrow等对象,原来均是以CCXXXTransition命名,而今变成了CCTransitionXXX。
例如: 
      1.0版本以下                           1.0版本及以上 
CCShrinkGrowTransition       CCTransitionShrinkGrow 
CCSlideInRTransition             CCTransitionSlideInR 
CCSlideInRLransition              CCTransitionSlideInL 

3   CCBitmapFontAtlas对象没用了,改称了CCLabelBMFont。
 
1.0版本以前的用法: 
Java代码   收藏代码
  1. CCBitmapFontAtlas *lbScore = [CCBitmapFontAtlas bitmapFontAtlasWithString:@"Time: 0" fntFile:@"font09.fnt"];  

1.0版本及以后的用法: 
Java代码   收藏代码
  1. CCLabelBMFont *lbScore = [CCLabelBMFont labelWithString:@"Time: 0" fntFile:@"font09.fnt"];  


4  CCSpriteSheet对象也没有了,改成了CCSpriteBatchNode
 
1.0版本以前的用法: 
Java代码   收藏代码
  1. CCSpriteSheet *mgr = [CCSpriteSheet spriteSheetWithFile:@"flight.png" capacity:5];  

1.0版本及以后的用法: 
Java代码   收藏代码
  1. CCSpriteBatchNode *mgr = [CCSpriteBatchNode batchNodeWithFile:@"flight.png" capacity:5];  


5  CCAnimation的animationWithName方法已被deprecated,改成了animationWithSpriteFrames
 
原用法: 
Java代码   收藏代码
  1. CCAnimation *animation = [CCAnimation animationWithName:@"flight" delay:0.2f];  

1.0版本及以后的用法: 
Java代码   收藏代码
  1. CCTexture2D *texture = [[CCTextureCache sharedTextureCache] addImage:@"flight.png"];  
  2. CCSpriteFrame *frame = [CCSpriteFrame frameWithTexture:texture rect:CGRectMake(00, texture.contentSize.width, texture.contentSize.height)];  
  3. NSArray *array = [[NSArray alloc] initWithObjects:frame, nil];  
  4. CCAnimation *animation = [CCAnimation animationWithSpriteFrames:array delay:0.2f];  



版本更新问题: 
在编译这个的时候,出现了如标题中的错误
Java代码   收藏代码
  1. + (id) layerWithColor:(ccColor4B)color  
  2. {  
  3.         return [[[self alloc] initWithColor:color] autorelease];  
  4. }  


刚开始是搜索的错误,找了一大堆的英文的解决办法,包括那个大名鼎鼎的啥米溢出论坛,但是没结果,后来看到这个论坛的朋友给出了结果,觉得还是同胞亲哪。 

11L大神给出了解决办法 

在[self alloc]前面加上(ColorLayer*),如下:
Java代码   收藏代码
  1. + (id) layerWithColor:(ccColor4B)color  
  2. {  
  3.         return [[(ColorLayer*)[self alloc] initWithColor:color] autorelease];  
  4. }  

在新版本的cocos2d中ColorLayer更新为CCColorLayer了或者是CCLayerColor,两者是一样的。


转载自:  http://lizi07.iteye.com/blog/1517652

转载于:https://my.oschina.net/u/139546/blog/374113

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值