I haven't updated my blog for a while. I think the level is really enough and I can't bear it out ~~~~
Yesterday, cocos2dx 3.0 beta was released. I used alpha1 for a week or two before, so I decided to write some blog posts about 3.0, not only do I have some personal understandings and opinions, but I also post the problems encountered during the development process ~~
1. CC is removed from classes starting with CC, for example:
| v2.1 | v3.0 || CCSprite | Sprite || CCNode | Node || CCDirector | Director || etc... |
For example, how to create an genie:
v2.0 CCSprite* sp = CCSprite::create();v3.0auto sp = Sprite::create();
2. Replace copy () with clone (). I don't use much of it, so I won't explain it much;
3. Replace Director's Singleton with getInstance () and destroyInstance ();
| v2.1 | v3.0 || CCDirector->sharedDirector() | Director->getInstance() || CCDirector->endDirector() | Director->destroyInstance() || etc... |
|
4. The new touch mechanism should be pasted with a piece of code for you to see. It may be the next one or the next one. I will elaborate on the new touch mechanism. (Hey, it seems so cool to me)
auto sprite = Sprite::create("file.png");...auto listener = EventListenerTouchOneByOne::create();listener->setSwallowTouch(true);listener->onTouchBegan = [](Touch* touch, Event* event) { do_some_thing(); return true; };listener->onTouchMoved = [](Touch* touch, Event* event) { do_some_thing(); };listener->onTouchEnded = [](Touch* touch, Event* event) { do_some_thing(); };listener->onTouchCancelled = [](Touch* touch, Event* event) { do_some_thing(); };// The priority of the touch listener is based on the draw order of spriteEventDispatcher::getInstance()->addEventListenerWithSceneGraphPriority(listener, sprite);// Or the priority of the touch listener is a fixed valueEventDispatcher::getInstance()->addEventListenerWithFixedPriority(listener, 100); // 100 is a fixed value
5. There are some miscellaneous things that I can't understand, so I won't show myself ugly. I finally posted some changes in CCType. h, so that we can end this blog happily.
| 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 |
Some global definitions:
// in v2.1ccColor3B color3B = ccc3(0, 0, 0);ccc3BEqual(color3B, ccc3(1, 1, 1));ccColor4B color4B = ccc4(0, 0, 0, 0);ccColor4F color4F = ccc4f(0, 0, 0, 0);color4F = ccc4FFromccc3B(color3B);color4F = ccc4FFromccc4B(color4B);ccc4FEqual(color4F, ccc4F(1, 1, 1, 1));color4B = ccc4BFromccc4F(color4F);color3B = ccWHITE;// in v3.0Color3B color3B = Color3B(0, 0, 0);color3B.equals(Color3B(1, 1, 1));Color4B color4B = Color4B(0, 0, 0, 0);Color4F color4F = Color4F(0, 0, 0, 0);color4F = Color4F(color3B);color4F = Color4F(color4B);color4F.equals(Color4F(1, 1, 1, 1));color4B = Color4B(color4F);color3B = Color3B::WHITE;
Continue...
| 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 |
For more information, see the official documentation:
Https://github.com/cocos2d/cocos2d-x/blob/develop/docs/RELEASE_NOTES.md