为了正常的体验网站,请在浏览器设置里面开启Javascript功能!

block实现场景切换

2013-03-14 2页 doc 28KB 10阅读

用户头像

is_200441

暂无简介

举报
block实现场景切换loadingLayer=[LoadingLayer node]; 谛力泰克网 :app定制 http://www.dilitech.com [self addChild:loadingLayer]; dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0); dispatch_async(queue, ^{ //声明一个Pool来自动管理指针 NSA...
block实现场景切换
loadingLayer=[LoadingLayer node]; 谛力泰克网 :app定制 http://www.dilitech.com [self addChild:loadingLayer]; dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0); dispatch_async(queue, ^{ //声明一个Pool来自动管理指针 NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init]; //加锁保护,并保证与Cocos2d本身的异步加载函数本身不冲突 //也就是保护ShareGroup不被同时修改 // [[CCTextureCache sharedTextureCache].contextLock lock]; //auxGLcontext必须是static // if( auxGLcontext == nil ) { //新建一个EAGLContext 然后与已经生成与使用的OpenGL公用一个ShareGroup auxGLcontext = [[EAGLContext alloc]initWithAPI:kEAGLRenderingAPIOpenGLES1 sharegroup:[[[[CCDirector sharedDirector] openGLView] context] sharegroup]]; //检查是否 if( ! auxGLcontext ) CCLOG(@"cocos2d: TextureCache: Could not create EAGL context"); } CCScene *scene; //设置Context,拥有修改权利,接下来我们就可以正常的使用我们生成我们自己的Scene了 if( [EAGLContext setCurrentContext:auxGLcontext] ) { //初始化 scene = [LevelController scene]; [[CCDirector sharedDirector] replaceScene:scene]; } //回到主线程,保留并解锁,然后等等主线程接收方响应并开始切换场景 dispatch_async(dispatch_get_main_queue(), ^{ //防止指针丢失 // nextScene = [scene retain]; //lock用来判断scene是否生存完 // lock = NO; }); //恢复 [EAGLContext setCurrentContext:nil]; // [[CCTextureCache sharedTextureCache].contextLock unlock]; [autoreleasepool release]; }); 复制代码 如果用下列常规方式回出现场景图片与动画均显示不了的问 loadingLayer=[LoadingLayer node]; [self addChild:loadingLayer]; dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); dispatch_async(queue, ^{ CCScene *levelScene = [LevelController scene]; [[CCDirector sharedDirector] replaceScene:levelScene]; dispatch_async(dispatch_get_main_queue(), ^{ [loadingLayer removeFromParentAndCleanup:YES]; }); }); 复制代码 文章出处:谛力泰克网 app开发 http://www.dilitech.com
/
本文档为【block实现场景切换】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。 本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。 网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。

历史搜索

    清空历史搜索