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];
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值