Cocos2d-x   发布时间:2022-05-03  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了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];

大佬总结

以上是大佬教程为你收集整理的Cocos2D v2.0至v3.x简洁转换指南(三)全部内容,希望文章能够帮你解决Cocos2D v2.0至v3.x简洁转换指南(三)所遇到的程序开发问题。

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

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。