Cocos2D v2.0至v3.x简洁转换指南三

Cocos2D 3.3中的注意事项

如果你在使用Cocos2D 3.3+(是SpriteBuilder 1.3+的一部分)你将不得不替分别的换所有存在的UITouch和UITouchEvent为CCTouch和CCTouchEvent。

你可以在SpriteBuilder的升级手册中找到更多信息。

再见 Ccmenu!Hello cclayout!

在过去Ccmenu是创建菜单最简单的方法。因为Ccmenu是提供布局处理方法的仅有的类(alignItemsvertically,等等).该类过去被用来布局大量其它的东西,不仅仅是菜单

Cocos2d 3.0提供一个cclayout类来解决该问题。该类可以布局任何种类的CCNode对象,使得布局你的场景显得更有吸引力。如果你要在Cocos2d 3.0中创建一个菜单,你可以将CCButtons简单的添加cclayout容器中去。

下面是一个简单布局的例子:

// create first button
self.calculationStepButton = [CCButton buttonWithTitle:LABEL_STEP];
[self.calculationStepButton setTarget:self selector:@selector(calculationStepButtonTouched:)];
// create second button
self.animationButton = [CCButton buttonWithTitle:LABEL_ANIMATE];
[self.animationButton setTarget:self selector:@selector(animateButtonTouched:)];
// setup layoutBox and add items
cclayoutBox *layoutBox = [[cclayoutBox alloc] init];
layoutBox.anchorPoint = ccp(0.5,0.5);
[layoutBox addChild:self.calculationStepButton];
[layoutBox addChild:self.animationButton];
layoutBox.spacing = 10.f;
layoutBox.direction = cclayoutBoxDirectionVertical;
[layoutBox layout];
layoutBox.position = ccp(CANVAS_SIZE.width + (self.contentSize.width - CANVAS_SIZE.width)/2,self.contentSize.height/2);
[self addChild:layoutBox];

相关文章

    本文实践自 RayWenderlich、Ali Hafizji 的文章《...
Cocos-code-ide使用入门学习地点:杭州滨江邮箱:appdevzw@1...
第一次開始用手游引擎挺激动!!!进入正题。下载资源1:从C...
    Cocos2d-x是一款强大的基于OpenGLES的跨平台游戏开发...
1.  来源 QuickV3sample项目中的2048样例游戏,以及最近《...
   Cocos2d-x3.x已经支持使用CMake来进行构建了,这里尝试...