gtts微薄

在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];这样才真正的从内存中释放掉~






posted @ 2012-03-25 09:58  gtts  阅读(614)  评论(0编辑  收藏  举报