cocos2d 1.0及以上版本与0.xx版本某些类的变化
2012-12-28 14:24
375 查看
1 CCMenuItemFont的itemFromString: target: selector:方法,该方法已被deprecated。]
新方法使用如下:
Java代码
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代码
CCBitmapFontAtlas *lbScore = [CCBitmapFontAtlas bitmapFontAtlasWithString:@"Time: 0" fntFile:@"font09.fnt"];
1.0版本及以后的用法:
Java代码
CCLabelBMFont *lbScore = [CCLabelBMFont labelWithString:@"Time: 0" fntFile:@"font09.fnt"];
4 CCSpriteSheet对象也没有了,改成了CCSpriteBatchNode
1.0版本以前的用法:
Java代码
CCSpriteSheet *mgr = [CCSpriteSheet spriteSheetWithFile:@"flight.png" capacity:5];
1.0版本及以后的用法:
Java代码
CCSpriteBatchNode *mgr = [CCSpriteBatchNode batchNodeWithFile:@"flight.png" capacity:5];
5 CCAnimation的animationWithName方法已被deprecated,改成了animationWithSpriteFrames
原用法:
Java代码
CCAnimation *animation = [CCAnimation animationWithName:@"flight" delay:0.2f];
1.0版本及以后的用法:
Java代码
CCTexture2D *texture = [[CCTextureCache sharedTextureCache] addImage:@"flight.png"];
CCSpriteFrame *frame = [CCSpriteFrame frameWithTexture:texture rect:CGRectMake(0, 0, texture.contentSize.width, texture.contentSize.height)];
NSArray *array = [[NSArray alloc] initWithObjects:frame, nil];
CCAnimation *animation = [CCAnimation animationWithSpriteFrames:array delay:0.2f];
版本更新问题:
在编译这个的时候,出现了如标题中的错误
Java代码
+ (id) layerWithColor:(ccColor4B)color
{
return [[[self alloc] initWithColor:color] autorelease];
}
刚开始是搜索的错误,找了一大堆的英文的解决办法,包括那个大名鼎鼎的啥米溢出论坛,但是没结果,后来看到这个论坛的朋友给出了结果,觉得还是同胞亲哪。
11L大神给出了解决办法
在[self alloc]前面加上(ColorLayer*),如下:
Java代码
+ (id) layerWithColor:(ccColor4B)color
{
return [[(ColorLayer*)[self alloc] initWithColor:color] autorelease];
}
在新版本的cocos2d中ColorLayer更新为CCColorLayer了或者是CCLayerColor,两者是一样的。
转载自: http://lizi07.iteye.com/blog/1517652
新方法使用如下:
Java代码
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代码
CCBitmapFontAtlas *lbScore = [CCBitmapFontAtlas bitmapFontAtlasWithString:@"Time: 0" fntFile:@"font09.fnt"];
1.0版本及以后的用法:
Java代码
CCLabelBMFont *lbScore = [CCLabelBMFont labelWithString:@"Time: 0" fntFile:@"font09.fnt"];
4 CCSpriteSheet对象也没有了,改成了CCSpriteBatchNode
1.0版本以前的用法:
Java代码
CCSpriteSheet *mgr = [CCSpriteSheet spriteSheetWithFile:@"flight.png" capacity:5];
1.0版本及以后的用法:
Java代码
CCSpriteBatchNode *mgr = [CCSpriteBatchNode batchNodeWithFile:@"flight.png" capacity:5];
5 CCAnimation的animationWithName方法已被deprecated,改成了animationWithSpriteFrames
原用法:
Java代码
CCAnimation *animation = [CCAnimation animationWithName:@"flight" delay:0.2f];
1.0版本及以后的用法:
Java代码
CCTexture2D *texture = [[CCTextureCache sharedTextureCache] addImage:@"flight.png"];
CCSpriteFrame *frame = [CCSpriteFrame frameWithTexture:texture rect:CGRectMake(0, 0, texture.contentSize.width, texture.contentSize.height)];
NSArray *array = [[NSArray alloc] initWithObjects:frame, nil];
CCAnimation *animation = [CCAnimation animationWithSpriteFrames:array delay:0.2f];
版本更新问题:
在编译这个的时候,出现了如标题中的错误
Java代码
+ (id) layerWithColor:(ccColor4B)color
{
return [[[self alloc] initWithColor:color] autorelease];
}
刚开始是搜索的错误,找了一大堆的英文的解决办法,包括那个大名鼎鼎的啥米溢出论坛,但是没结果,后来看到这个论坛的朋友给出了结果,觉得还是同胞亲哪。
11L大神给出了解决办法
在[self alloc]前面加上(ColorLayer*),如下:
Java代码
+ (id) layerWithColor:(ccColor4B)color
{
return [[(ColorLayer*)[self alloc] initWithColor:color] autorelease];
}
在新版本的cocos2d中ColorLayer更新为CCColorLayer了或者是CCLayerColor,两者是一样的。
转载自: http://lizi07.iteye.com/blog/1517652
相关文章推荐
- cocos2d 1.0及以上版本与0.xx版本某些类的变化
- 转载]cocos2d中CCAnimation的使用(cocos2d 1.0以上版本)
- cocos2d-x读取xml(适用于cocos2d-x 2.0以上版本)
- 从读取图像程序比较opencv1.0与opencv2.0以上版本
- MTK Android 5.0以上版本的变化
- Cocos2d-x 3.0及以上版本资源及脚本解密
- cocos2d-x win32移植到android(NDK R7版本以上)
- Android BroadCast 各种注册和发送方式的特点整理以及7.0以上版本的使用变化
- io.sockets.socket(id)在1.0版本中的变化
- 使用TensorFlow1.0及以上版本的问题
- 【Auto Layout】Xcode6及以上版本,创建Auto Layout 约束时产生的一些变化【iOS开发教程】
- Cocos API风格说明(Cocos2d-xV3.0以上版本)
- cocos2d-x如何添加精灵动画(适合于2以上的版本)
- Cocos2d-x v3.2笔记——总结Cocos2d-x 3.x版本的一些变化
- Mac系统下搭建Cocos2d-x开发环境及2.20以上版本如何创建HelloWorld
- Cocos2d-x 2.20及以上版本如何创建基于Lua的项目
- 【教程】cocos2d-x2.2以上版本 win/mac 安装步骤
- 网络首发cocos2d-x手游《打小三》V1.0版本的win32版本
- cocos2d-x 2.0.2升级后某些函数变化(转)
- cocos2d-x 1.0版本 自适应屏幕分辨率