在cocos2d中添加UIKit组件

为了防止操作组件时cocos2d的动画停止不动,找到CCDirectorIOS.m文件,找到如下代码:

//
// If you want to attach the opengl view into UIScrollView
// uncomment this line to prevent 'freezing'.
// It doesn't work on with the Fast Director
//
// [[NSRunLoop currentRunLoop] addTimer:animationTimer
//

去掉注释。然后在AppDelegate.m中华将下面代码注释:

 if( ! [CCDirector setDirectorType:kCCDirectorTypeDisplayLink] )

 

创建一个UIViewController类,名字为: MyUIViewController

自己根据需要添加内容

然后修改HelloWorldLayout.m

-(id) init
{

if( (self=[super init])) {

MyUIView *view = [[MyUIView alloc] initWithNibName:@"MyUIView" bundle:nil];
[[[CCDirector sharedDirector] openGLView] addSubview:view.view];

}
return self;
}

删除添加的组件:

[self.updateUIView.view removeFromSuperview];

这样后还要加上[self.updateUIView.view release];这样才真正的从内存中释放掉~






转载于:https://www.cnblogs.com/gtts/archive/2012/03/25/2416368.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值