(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-js】是基于Cocos2d-x引擎的JavaScript版本,它允许开发者使用JavaScript语言进行2D游戏开发,具有跨平台的特性,能够运行在网页、Android和iOS等多个平台上。以下将详细讲解cocos2d-js的搭建配置、工程...
cc.COCOS2D_DEBUG = this.config['COCOS2D_DEBUG']; cc.initDebugSetting(); cc.setup(this.config['tag']); cc.Loader.getInstance().onloading = function() { cc.LoaderScene.getInstance().draw(); }; cc...
在Cocos2d-x游戏开发框架中,XML解析是一个重要的环节,它允许开发者处理和读取XML格式的数据,这些数据可以包含游戏配置、资源引用、关卡设计等信息。XML(eXtensible Markup Language)是一种标记语言,因其结构...
在cocos2d-x游戏开发框架中,异步加载(Asynchronous Loading)是优化资源管理的重要策略,特别是在处理大量数据如plist文件时。Plist文件通常用于存储图像、动画序列或者配置信息,它们以XML或二进制格式保存。在...
`cocos2d.js`文件包含了一些配置选项,如调试级别(COCOS2D_DEBUG)、是否启用Box2D物理引擎、是否显示帧率(showFPS)以及帧率的设置(frameRate)。其中,`appFiles`数组列出了需要加载的所有应用程序文件,包括...
在Cocos2dx游戏开发中,加载界面(Loading Screen)是一个重要的组成部分,它通常用于处理游戏启动时的数据加载和初始化工作,确保用户在等待期间有一个良好的体验。Cocos2dx是一个开源的游戏开发框架,基于C++,...
在描述中提到的"LoadingLayer::onEnter()",这是Cocos2d-x中场景层(Layer)的一个生命周期方法,当该层进入视图时会被调用。在onEnter()中启动新线程进行加载,可以确保资源加载过程不会阻塞用户界面,用户可以看到...
cc.COCOS2D_DEBUG = this.config['COCOS2D_DEBUG']; cc.initDebugSetting(); cc.setup(this.config['tag']); cc.Loader.getInstance().onloading = function(){ cc.LoaderScene.getInstance().draw(); }; cc....
cc.COCOS2D_DEBUG = this.config['COCOS2D_DEBUG']; cc.initDebugSetting(); cc.setup(this.config['tag']); cc.Loader.getInstance().onloading = function () { cc.LoaderScene.getInstance().draw(); }; ...
Cocos2d-x是一款流行的开源跨平台2D游戏开发框架,它使用C++作为主要编程语言,同时也支持Lua和JavaScript。在游戏开发过程中,加载界面是必不可少的一部分,它为玩家提供了一个可视化的等待过程,展示游戏资源的...
创建一个名为`LoadingScene`的类,继承自`cocos2d::Layer`。在这个类中,我们需要初始化加载界面的各种元素,如进度条、百分比显示等,并设置一个定时器以更新加载进度。 1. **进度条实现**:可以使用`Sprite`类...
在iOS应用开发中,特别是在使用Cocos2d游戏引擎时,"loading场景切换"是一个重要的技术环节。这个过程涉及到如何优雅地处理用户界面,保证在应用程序加载大量资源或执行复杂操作时提供良好的用户体验。以下是对这个...
cocos2dx_3d开发的飞机大战,包括源码和资源,mac xcode整长运行!windows自己导入调试。包括player场景,loading场景,战斗场景,效果酷炫,还有多机型适配处理方案!非常有价值!适合自学和二次开发!
cocos2d-x-3.x版本进行了很多优化,比如:将TTF字体用Atlas缓存,节点重排序官方声称提升了10倍速度,查找、移除节点方面也提高了10%,拆分渲染层到独立的线程运行; 另外,coco2d-x3.x版本还采用C++标准,大量使用std...
9. **优化性能**:为了提高页面加载速度,可以使用懒加载(lazy loading)技术,只在切换到特定内容面板时才加载其内容。 10. **插件与库的使用**:虽然这个资源没有明确提到,但许多开发者可能会使用现有的...
Cocos2d-iOS支持Tile Maps,并提供了CC TMX Layer和CC TMX Map类来处理地图数据。 2. **TMX文件格式**:TMX是Tiled Map Editor使用的XML格式,用于存储地图信息,包括瓦片集、层、对象组等。在...
Cocos2d-x提供了内置的特效系统,通过封装方法我们可以灵活调整这些特效的效果,如粒子爆炸、光影变化等。同时,学习并使用粒子编辑器,如Cocos Studio或SParkleX,可以让开发者创造出更多样化的视觉特效,提高游戏...
Kode 是为了结合使用 cocos2d-x 框架开发移动游戏而开发一个轻量级 MVC 框架。Kode 已经应用在一款大型的横版格斗手游,实用性和稳定性都可以保证,同时 Kode 也会持续地更新,随着项目开发 Kode 已更新到 v3 了,v3...
标签中提到的“cocos”,通常指的是Cocos2d-x,这是一个跨平台的游戏开发框架,支持JavaScript、C++等多种语言。在微信小程序中,Cocos可以用于开发高性能的游戏或交互性强的应用。使用Cocos,开发者可以利用其强大...
解决方案:如果使用的是cocos2d-x 4.0以上的版本,可能是因为该版本不兼容cocos studio的原因,建议安装3.15以前的版本。 知识点1:cocos2d-x版本兼容性 cocos2d-x是一个开源的跨平台游戏引擎,支持多种平台和语言...