(id) init
{
self = [super init];
if ( self )
{
// Add the Label (in cocos2D universe)
BitmapFontAtlas *label = [BitmapFontAtlas
bitmapFontAtlasWithString: @"Initializing Game"
fntFile: @"comic_atlas.fnt"
alignment: UITextAlignmentCenter];
label.position = ccp(240, 160);
label.opacity = 0;
[self addChild: label z: 0 tag: kInitializingLabel];
// Add the UIActivityIndicatorView (in UIKit universe)
self.activityIndicatorView = [[[UIActivityIndicatorView alloc]
initWithActivityIndicatorStyle:
UIActivityIndicatorViewStyleWhiteLarge] autorelease];
activityIndicatorView.center = ccp(190,240);
[activityIndicatorView startAnimating];
[[self battleView] addSubview: activityIndicatorView];
[self schedule: @selector(loadingInit)];
// At this point, the cocos2d rendering is fine.
}
return self;
}
- (void) loadingInit
{
[self unschedule: @selector(loadingInit)];
// Fade in nicely
BitmapFontAtlas *label = (BitmapFontAtlas*)[self getChildByTag: kInitializingLabel];
[label runAction: [FadeIn actionWithDuration: .25]];
[self schedule: @selector(loadingStep0) interval: .25];
}
- (void) loadingStep0
{
[self unschedule: @selector(loadingStep0)];
// Add you own code to load texture, sounds etc...
// The cocos2D thread will be waiting (since it's the same as
the main thread) but the UIKit thread will keep running in parallel
// Can do multiple steps or just one
[self schedule: @selector(loadingStep1) interval: .5];
}
- (void) loadingStep1
{
[self unschedule: @selector(loadingStep1)];
// Add you own code to load texture, sounds etc...
[self schedule: @selector(loadingDone) interval: .1];
}
- (void) loadingDone
{
gameIsReady = YES;
[self.activityIndicatorView removeFromSuperview];
BitmapFontAtlas *label = (BitmapFontAtlas*)[self getChildByTag: kInitializingLabel];
[label setString: NSLocalizedString(@"Tap to start!", nil)];
[label runAction: [RepeatForever actionWithAction:
[Sequence actionOne: [EaseInOut actionWithAction:
[MoveTo actionWithDuration: .6 position: ccp(210, 160)] rate: 2]
two: [EaseInOut actionWithAction:
[MoveTo actionWithDuration: .6 position: ccp(270, 160)] rate: 2]
]
]
];
}
- (BOOL)ccTouchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
if ( gameIsReady )
{
[self openGame];
}
return kEventHandled;
}
http://stackoverflow.com/questions/1133123/multi-threaded-opengl-programming-in-cocos2d-iphone
分享到:
相关推荐
资源名称:Cocos2d-x实战:JS卷——Cocos2d-JS开发内容简介:本书是介绍Cocos2d-x游戏编程和开发技术书籍,介绍了使用Cocos2d-JS中核心类、瓦片地图、物理引擎、音乐音效、数据持久化、网络通信、性能优化、多平台...
cocos2d入门 cocos2d入门 cocos2d入门 cocos2d入门 cocos2d入门 cocos2d入门
该资源主要用于cocos2d-x中Value与json字符串的相互转换,提供从json文件读取为cocos2d::Value,cocos2d::Value写入到文件,cocos2d::Value转换为json字符串,json字符串转换为cocos2d::Value。json字符串转换成cocos...
cocos2d-x-2.1.5
第1章 开始前的准备工作 1 第2章 你的第一款iPhone游戏:垂直射击游戏 38 第3章 Cocos2D核心类 69 第4章 Cocos2D中的动作、特效与动画 152 第5章 Cocos2D中的文本渲染系统 229 共19章
在使用cocos2d-x开发游戏的过程中,为了实现逻辑和显示相分离。 在下通宵了一个晚上,写出了该事件类。 谨记,该事件只能用于cocos2d-x中。 事件发送者需要继承EventDispatcher类 事件接收者需要继承EventHandle类...
Ray Wenderlich的《Cocos2d SimpleGame》,被认为是cocos2d的初学者最好的教程,这本书被Cocos2D-X团队从objective-c转化到了c++版,并发布在了github上。在此感谢Ray Wenderlich的慷慨相助。 源代码是在cocos2d-x ...
cocos2d-x游戏代码
Cocos2d-x是移动跨平台开发最流行的游戏引擎,而本书是一本很全面的、比较‘接地气’的游戏开发教程。书中汇聚了热门手机游戏《捕鱼达人》开发的实战经验,作者从最基础的内容开始,逐步深入地介绍了Cocos2d-x的相关...
Cocos2d-x实战 JS卷 Cocos2d-JS开发 PDF 电子书完整版本
如果你想用cocos2d开发android游戏,但是又不方便找包,这里就可以为你提供cocos2d开发的所有相关包,解压后得到libs文件夹即可。
Cocos2d-x源于Cocos2d,是一款开源游戏引擎项目,是一款基于对原有iOS平台cocos2d重写为C++的开源代码,封装了OpenGL,Box2d,LibCurl,LibPng等开源的跨平台代码。由于基于C++和STL特点使其广泛应用于游戏开发、移动...
cocos2d的学习资料,一本比较经典的cocos2d开发书,适合cocos2d/cocos2d-x的入门
Cocos2d-x实战
cocos2d-x实战项目 01.cocos2d-x原理及环境配置.rar 03.cocostudio使用方法及UI控制.rar 04.XML文件读取与骨骼动画.rarcocos2d-x实战项目 01.cocos2d-x原理及环境配置.rar 03.cocostudio使用方法及UI控制.rar 04.XML...
windows环境,一款很好用cocos2d粒子特效编辑器,里面有不少例子
cocos2d-x 3.0 人物行走 . 包里有代码和 图片资源.
资源名称:大富翁手机游戏开发实战基于Cocos2d-x3.2引擎内容简介:李德国编著的《大富翁手机游戏开发实战(基于 Cocos2d-x3.2引擎)》使用Cocos2d-x游戏引擎技术,带领读者一步一步从零开始进行大富翁移动游戏的开发...
本人提交源码进行了版本移植并修改了一个bug,目前使用VS2008+cocos2d-x,2.0.4版本编译测试过(需要注意的是,我的IDE环境中是将COCOS2d-x的头文件和库文件设置到了VS环境中对所有项目生效,并没有单独对特定的COCOS...
资源名称:Cocos2D-X游戏开发技术精解内容简介:Cocos2D-X是一款支持多平台的 2D手机游戏引擎,支持iOS、Android、BlackBerry等众多平台。当前,很多移动平台流行的游戏,都是基于Cocos2D-X开发的。 《Cocos2D-X...