读书人

UIView加入cocos2d视图奇效(基于UIKi

发布时间: 2013-11-01 14:43:02 作者: rapoo

UIView加入cocos2d视图特效(基于UIKit)

源码:https://github.com/weedcatch/Demo_UIViewAddCocos2d


一、初始opengl视图

注意:该视图属于project已经添加的视图。

-(void)runScene:(CCScene*)aScene inView:(UIView*)aSupView{    //self.supView = aSupView;    if ([CCDirector sharedDirector].runningScene !=nil) {        [[CCDirector sharedDirector].runningScene cleanup];        [[CCDirector sharedDirector] replaceScene:aScene];    }else{        [[CCDirector sharedDirector] runWithScene:aScene];    }    //add to view    UIView *aView;    BOOL hasIn = NO;    for (aView in aSupView.subviews) {        if (aView == _glView) {            [aSupView bringSubviewToFront:_glView];            hasIn = YES;        }    }    if (!hasIn) {        [aSupView addSubview:_glView];        [aSupView bringSubviewToFront:_glView];    }}




读书人网 >操作系统

热点推荐