Cocos2d-x   发布时间:2022-05-02  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了cocos2dx 3.0一些变化大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

转自http://blog.csdn.net/start530/article/details/18052953


1、以CC开头的类从此去掉CC,如:

| v2.1       | v3.0     |
| CCSprite   | Sprite   |
| CCNode     | Node     |
| CCDirector | Director |
| etc...                |

举个例子,创建一个精灵的方式:
  1. v2.0
  2. CCSprite*sp=CCSprite::create();
  3. v3.0
  4. autosp=Sprite::create();


2、clone() 替代 copy(),这个我用的不多,所以也就不多交代了;
3、Director的单例换成geTinstance() 和 destroyInstance();
| v2.1                          | v3.0                        |
| CCDirector->sharedDirector()  | Director->geTinstance()     |
| CCDirector->endDirector()     | Director->destroyInstance() |
| etc...                                                      |
|
4、新的触摸机制,先贴一段代码给大家看看,可能是下一篇或者下下篇我会详细讲下新的触摸机制的。
    autosprite=Sprite::create("file.png");
  1. ...
  2. autolistener=EventListenerTouchOneByOne::create();
  3. listener->setSwallowTouch(true);
  4. listener->onTouchBegan=[](Touch*touch,Event*event){do_some_thing();returntrue;};
  5. listener->onTouchMoved=[](Touch*touch,Event*event){do_some_thing();};
  6. listener->onTouchEnded=[](Touch*touch,Event*event){do_some_thing();};
  7. listener->onTouchCancelled=[](Touch*touch,108); list-style:decimal-leading-zero outside; color:inherit; line-height:18px; margin:0px!important; padding:0px 3px 0px 10px!important"> //Thepriorityofthetouchlistenerisbasedonthedraworderofsprite
  8. EventDispatcher::geTinstance()->addEventListenerWithSceneGraphpriority(listener,spritE);
  9. //Orthepriorityofthetouchlistenerisafixedvalue
  10. EventDispatcher::geTinstance()->addEventListenerWithFixedPriority(listener,100);//100isafixedvalue

5、还有一些杂七杂八的东西,本人理解的不透,也就不发出来献丑了,最后将CCType.h 里的一些变动贴出来,让我们愉快的结束这篇博文。
| v2.1 struct names | v3.0 struct names | | ccColor3B | Color3B | | ccColor4B | Color4B | | ccColor4F | Color4F | | ccVertex2F | Vertex2F | | ccVertex3F | Vertex3F | | ccTex2F | Tex2F | | ccPointSprite | PointSprite | | ccQuad2 | Quad2 | | ccQuad3 | Quad3 | | ccV2F_C4B_T2F | V2F_C4B_T2F | | ccV2F_C4F_T2F | V2F_C4F_T2F | | ccV3F_C4B_T2F | V3F_C4B_T2F | | ccV2F_C4B_T2F_Triangle | V2F_C4B_T2F_Triangle | | ccV2F_C4B_T2F_Quad | V2F_C4B_T2F_Quad | | ccV3F_C4B_T2F_Quad | V3F_C4B_T2F_Quad | | ccV2F_C4F_T2F_Quad | V2F_C4F_T2F_Quad | | ccBlendFunc | BlendFunc | | ccT2F_Quad | T2F_Quad | | ccAnimationFrameData | AnimationFrameData |

一些全局的定义

// in v2.1
ccColor3B color3B = ccc3(0, 0);
ccc3BEqual(color3B, ccc3(1,153)">1));
ccColor4B color4B = ccc4(0);
ccColor4F color4F = ccc4f(0);
color4F = ccc4FFromccc3B(color3B);
color4F = ccc4FFromccc4B(color4B);
ccc4FEqual(color4F, ccc4F(1));
color4B = ccc4BFromccc4F(color4F);

color3B = ccWHITE;

// in v3.0
Color3B color3B = Color3B(0);
color3B.equals(Color3B(1));
Color4B color4B = Color4B(0);
Color4F color4F = Color4F(0);
color4F = Color4F(color3B);
color4F = Color4F(color4B);
color4F.equals(Color4F(1));
color4B = Color4B(color4F);

color3B = Color3B::WHITE;

继续...

| v2.1 names    | v3.0 names |
| ccp           | Point |
| ccpNeg        | Point::- |
| ccpAdd        | Point::+ |
| ccpSub        | Point::- |
| ccpMult       | Point::* |
| ccpMidpoint   | Point::getMidpoint |
| ccpDot        | Point::dot |
| ccpCrosss     | Point::cross |
| ccpPerp       | Point::getPerp |
| ccpRPerp      | Point::getRPerp |
| ccpProject    | Point::project |
| ccpRotate     | Point::rotate |
| ccpUnrotate   | Point::unrotate |
| ccpLengthSQ   | Point::getLengthSq() |
| ccpDistanceSQ | Point::getDistanceSq |
| ccpLength     | Point::getLength |
| ccpDistance   | Point::getDistance |
| ccpNormalize  | Point::normalize |
| ccpForAngle   | Point::forAngle |
| ccpToAngle    | Point::getAngle |
| ccpClamp      | Point::getClampPoint |
| ccpFromSize   | Point::Point |
| ccpCompOp     | Point::compOp |
| ccpLerp       | Point::lerp |
| ccpFuzzyEqual | Point::fuzzyEqual |
| ccpCompMult   | Point::Point |
| ccpAngleSigned | Point::getAngle |
| ccpAngle      | Point::getAngle |
| ccpRotateByAngle | Point::rotateByAngle |
| ccpLineInersect | Point::isLineIntersect |
| ccpSegmenTintersect | Point::isSegmenTintersect |
| ccpIntersectPoint | Point::geTintersectPoint |
| CCPointMake   | Point::Point |
| CCSizeMake    | Size::Size |
| CCRectMake    | Rect::rect |
| PointZero     | Point::ZERO |
| SizeZero      | Size::ZERO |
| RectZero      | Rect::ZERO |
| TiledGrid3DAction::tile | TiledGrid3DAction::getTile |
| TiledGrid3DAction::originalTile | TiledGrid3DAction::getOriginalTile |
| TiledGrid3D::tile | TiledGrid3D::getTile |
| TiledGrid3D::originalTile | TiledGrid3D::getOriginalTile |
| Grid3DAction::vertex | Grid3DAction::getVertex |
| Grid3DAction::originalVertex | Grid3DAction::getOriginalVertex |
| Grid3D::vertex | Grid3D::getVertex |
| Grid3D::originalVertex | Grid3D::getOriginalVertex |
| Configuration::sharedConfiguration | Configuration::geTinstance |
| Configuration::purgeConfiguration | Configuration::destroyInstance() |
| Director::sharedDirector() | Director::geTinstance() |
| FileUtils::sharedFileUtils | FileUtils::geTinstance |
| FileUtils::purgeFileUtils | FileUtils::destroyInstance |
| EGLView::sharedopenGLView | EGLView::geTinstance |
| ShaderCache::sharedShaderCache | ShaderCache::geTinstance |
| ShaderCache::purgeSharedShaderCache | ShaderCache::destroyInstance |
| AnimationCache::sharedAnimationCache | AnimationCache::geTinstance |
| AnimationCache::purgeSharedAnimationCache | AnimationCache::destroyInstance |
| SpriteFrameCache::sharedSpriteFrameCache | SpriteFrameCache::geTinstance |
| SpriteFrameCache:: purgeSharedSpriteFrameCache | SpriteFrameCache::destroyInstance |
| NotificationCenter::sharedNotificationCenter | NotificationCenter::geTinstance |
| NotificationCenter:: purgeNotificationCenter | NotificationCenter::destroyInstance |
| Profiler::sharedProfiler | Profiler::geTinstance |
| UserDefault::sharedUserDefault | UserDefault::geTinstance |
| UserDefault::purgeSharedUserDefault | UserDefault::destroyInstance |
| Application::sharedApplication | Application::geTinstance |
| ccc3()        | Color3B() |
| ccc3BEqual()  | Color3B::equals() |
| ccc4()        | Color4B() |
| ccc4FFromccc3B() | Color4F() |
| ccc4f()       | Color4F() |
| ccc4FFromccc4B() | Color4F() |
| ccc4BFromccc4F() | Color4B() |
| ccc4FEqual()  | Color4F::equals() |
| ccWHITE       | Color3B::WHITE |
| ccYELLOW      | Color3B::YELLOW |
| ccBLUE        | Color3B::BLUE |
| ccGREEN       | Color3B::GREEN |
| ccRED         | Color3B::rED |
| ccMAGENTA     | Color3B::MAGENTA |
| ccBLACK       | Color3B::BLACK |
| ccORANGE      | Color3B::ORANGE |
| ccGRAY        | Color3B::GRAY |
| kBlendFuncDisable | BlendFunc::BLEND_FUNC_DISABLE |

大佬总结

以上是大佬教程为你收集整理的cocos2dx 3.0一些变化全部内容,希望文章能够帮你解决cocos2dx 3.0一些变化所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签:33.0cocoscocos2dxdx一些变化
猜你在找的Cocos2d-x相关文章
其他相关热搜词更多
phpJavaPython程序员load如何string使用参数jquery开发安装listlinuxiosandroid工具javascriptcap