第一个改动: CCLayer初始化
自定义Layer,类名:World
.h中:
1.x版本Layer函数
LAYER_NODE_FUNC(World);
2.x版本Layer函数
LAYER_CREATE_FUNC(World);
.cpp中:
1.x版本的重写函数:
CCScene* World::scene()
{
CCScene *scene = CCScene::node();
World *layer = World::node();
scene->addChild(layer);
return scene;
}
2.x版本的重写函数:
CCScene* World::scene()
{
CCScene *scene = CCScene::create();
World *layer = World::create();
scene->addChild(layer);
return scene;
}
然后我们看第二个常用的CCArray的初始化:
1.x版本的CCArray创建:
CCArray*array = CCArray::array();
2.x版本的CCArray创建:
CCArray*array = CCArray::create();
第三个我们看文件路径相关CCFileUtils函数使用:
1.x版本的使用:
const char* fullpath = cocos2d::CCFileUtils::fullPathFromRelativePath(patha.c_str());
2.x版本的使用:
const char* fullpath = cocos2d::CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(patha.c_str());
第四个精灵的创建:
1.x中精灵的创建:
CCSprite *sp = CCSprite::spriteWithFile("himi.png");
2.x中精灵的创建:
CCSprite *sp = CCSprite::create("himi.png");
第五个注册触屏事件监听:
1.x中注册:
CCTouchDispatcher::sharedDispatcher()->addTargetedDelegate(this, 0, false);
2.x中注册:
CCDirector::sharedDirector()->getTouchDispatcher()->addTargetedDelegate(this, 0, false);
第六个粒子相关
1.x粒子创建和设置自动释放设置
CCParticleSystem *tempSystem = CCParticleSystem::particleWithFile("himi.plist");
tempSystem->setIsAutoRemoveOnFinish(true);
2.x粒子创建和设置自动释放设置
CCParticleSystem *tempSystem = CCParticleSystemQuad::create("himi.plist");
tempSystem->setAutoRemoveOnFinish(true);
第七个:CCFileData 类去除了:
1.x的CCFileData的使用:
cocos2d::CCFileData fileDataClip(const char *pszFileName, const char *pszMode);
2.x中CCFileData被删除,直接使用如下函数即可代替:
CCFileUtils::sharedFileUtils()->getFileData(const char *pszFileName, const char *pszMode, unsigned long *pSize)
第八个 Action 动作使用与创建:
1.x动作的创建与使用:
this->runAction(CCSequence::actions(
CCMoveTo::actionWithDuration(ccpDistance(this->getPosition(), target) / velocity,
target),
CCCallFunc::actionWithTarget(this, callfunc_selector(Player::removeTarget))
,NULL));
2.x的动作创建和使用:
this->runAction(CCSequence::create(
CCMoveTo::create(ccpDistance(this->getPosition(), target) / velocity,
target),
CCCallFunc::create(this, callfunc_selector(Player::removeTarget))
,NULL));
分享到:
相关推荐
cocos2dx-3.x游戏开发之旅电子版供大家下载参考。。。。。。
cocos2dx3.x_shader仅供学习
cocos2dx 3.x 跨平台光标 简单易懂
cocos2dx3.x c++ 农场
cocos2dx3.x源代码资源
魔塔cocos2dx3.x版本
cocos2dx 3.x皇家守卫 iOS代码修改了一些bug,可以运行。用的cocos2d-x-3.16环境,将代码和素材直接拷贝进去就可以运行。
cocos2dx 2.x 开发示例游戏合集 效果展示: https://github.com/pdpdds/cocos2dx-dev/blob/master/img/snap0215.jpg https://github.com/pdpdds/cocos2dx-dev/blob/master/img/snap0216.jpg ...
原文地址:http://blog.csdn.net/teng_ontheway/article/details/39190919
cocos2dx 3.x的宝石消除类游戏demo,不是原创,自己收集的,挺不错的。
把 Birkemose 用 cocos2d-iphone v1.1 写的那个水波纹特效,用 cocos2dx v3.13 重新实现。 资源包括 原版 和我自己的改写版。
cocos2dx3.x_动作卡牌游戏,仅供学习!
cocos2dx3.x_cpp_tieldMap,仅供学习!
Cocos2dx 2.x版本播放mp4格式的文件 这里只是代码部分,还有.a文件,由于太大无法下载,有需要找本人私传给你
Cocos2d-x 3.x游戏开发之旅教程及完整源码下载,使用最新cocos2d-x-3.14版本,在xcode7.3上已编译通过。 解决相关问题 1、解决源程序在高版本上无法编译问题 2、解决源程序中文注释部分,xcode上显示乱码问题 使用...
C++开发,
cocos2d-x 3.x游戏开发实战肖文吉光盘源代码,共享学习
cocos2dx-classical, 对于仍然坚持 cocos2d x 2.2 的任何用户,都有更好的cocos2d x v2 这是一个私人定制的cocos2dx版本,基于cocos2dxv2分支的最新代码,目标是创造一个cocos2dx的古典经典版。cocos2dx已经全面发力...
http://blog.csdn.net/ctxdecs/article/details/43888399
Cocos2d-x v3.x中,对于事件的处理已经与Cocos2d-x v2.x中有天壤之别,本文讲述了3x的事件处理方式。