Cocos2D v2.0至v3.x简洁转换指南(三)
发布时间:2020-12-14 16:37:34 所属栏目:百科 来源:网络整理
导读:Cocos2D 3.3中的注意事项 如果你在使用Cocos2D 3.3+(是SpriteBuilder 1.3+的一部分)你将不得不替分别的换所有存在的UITouch和UITouchEvent为CCTouch和CCTouchEvent。 你可以在SpriteBuilder的升级手册中找到更多信息。 再见 CCMenu!Hello CCLayout! 在过
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];
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |