博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[iphone-cocos2d]关于Loading的若干处理和讨论
阅读量:7078 次
发布时间:2019-06-28

本文共 3018 字,大约阅读时间需要 10 分钟。

找了些关于loading的资源,贴出来慢慢看。 (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; } 2。 CGRect texRect = CGRectMake( (barPngWidth/2)*(1-loadPercentage), 0, barPngWidth/2, barPngHeight); [barAtlasSprite setTextureRect:textRect]; My loadPercentage var should be comprised between 0 and 1. You definitely don't have to use an animation nor the setDisplayFrame function. 3。http://stackoverflow.com/questions/1133123/multi-threaded-opengl-programming-in-cocos2d-iphone

转载地址:http://tdcml.baihongyu.com/

你可能感兴趣的文章
Android 8.0 系统和API的变化
查看>>
Git 多人协作开发流程
查看>>
js 时间对象的常规操作
查看>>
Centos 7 Yum方式安装Mongdb 3.4
查看>>
遇见大数据可视化 : 【云图】让数据可见
查看>>
Mac Docker 创建第一个Django 应用,Part 1
查看>>
zendAPI 的 CMake 参数详解
查看>>
【201天】黑马程序员27天视频学习笔记【Day18复习脑图】
查看>>
vue+webpack搭建单文件应用和多文件应用webpack.config.js的写法区别
查看>>
leetcode82. Remove Duplicates from Sorted List II
查看>>
简单学习node微信开发
查看>>
使用vue实现tab操作
查看>>
Yii2实现ActiveForm ajax提交
查看>>
【译】State and Lifecycle (State和生命周期)
查看>>
C接口与实现---之三
查看>>
浅析React之事件系统(一)
查看>>
解密新一代Java JIT编译器Graal
查看>>
HTTP协议:看个新闻原来这么麻烦
查看>>
服务平台化,知乎 HBase 实践
查看>>
2015年度最流行PHP框架调查结果出炉,Laravel居首
查看>>