cocos2d-iphone心得
源码下载地址:
http://code.google.com/p/cocos2d-iphone/downloads/list
https://github.com/cocos2d/cocos2d-iphone-classic/releases?after=release-0.2
问题:[[CCDirector sharedDirector] runWithScene: [sysMenu scene]];导演是怎么把screen放到屏幕上的呢?
找了老半天发现只有这个- (void) pushScene: (CCScene*) scene,把这个注了,就显示不了了,
后来又找了很长时间终于找到了,
EAGLView里
- (void) layoutSubviews
[director performSelectorOnMainThread:@selector(drawScene) withObject:nil waitUntilDone:YES];
-(void) mainLoop
{
[self drawScene];
}
- (void) startAnimation
{
NSAssert( isRunning == NO, @"isRunning must be NO. Calling startAnimation twice?");
// XXX:
// XXX: release autorelease objects created
// XXX: between "use fast director" and "runWithScene"
// XXX:
[autoreleasePool release];
autoreleasePool = nil;
if ( gettimeofday( &lastUpdate_, NULL) != 0 ) {
CCLOG(@"cocos2d: Director: Error in gettimeofday");
}
isRunning = YES;
SEL selector = @selector(mainLoop);
NSMethodSignature* sig = [[[CCDirector sharedDirector] class]
instanceMethodSignatureForSelector:selector];
NSInvocation* invocation = [NSInvocation
invocationWithMethodSignature:sig];
[invocation setTarget:[CCDirector sharedDirector]];
[invocation setSelector:selector];
[invocation performSelectorOnMainThread:@selector(invokeWithTarget:)
withObject:[CCDirector sharedDirector] waitUntilDone:NO];
// NSInvocationOperation *loopOperation = [[[NSInvocationOperation alloc]
// initWithTarget:self selector:@selector(mainLoop) object:nil]
// autorelease];
//
// [loopOperation performSelectorOnMainThread:@selector(start) withObject:nil
// waitUntilDone:NO];
}
- (void) startAnimation
{
NSAssert( displayLink == nil, @"displayLink must be nil. Calling startAnimation twice?");
if ( gettimeofday( &lastUpdate_, NULL) != 0 ) {
CCLOG(@"cocos2d: DisplayLinkDirector: Error on gettimeofday");
}
// approximate frame rate
// assumes device refreshes at 60 fps
int frameInterval = (int) floor(animationInterval_ * 60.0f);
CCLOG(@"cocos2d: Frame interval: %d", frameInterval);
displayLink = [NSClassFromString(@"CADisplayLink") displayLinkWithTarget:self selector:@selector(mainLoop:)];
[displayLink setFrameInterval:frameInterval];
[displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
}
cocos2d-iphone心得的更多相关文章
- (转载)如何学好iphone游戏开发
转自:http://www.cnblogs.com/zilongshanren/archive/2011/09/19/2181558.html 自从发布<如何学习iphone游戏开发>到 ...
- [cocos2d demo]新科娘收集水表
讲述的是新科娘在沙滩上遇到一大波水表的故事... 下载地址 链接:http://pan.baidu.com/share/link?shareid=2141087190&uk=293716439 ...
- 我常用的iphone开发学习网站[原创]
引用地址:http://www.cnblogs.com/fuleying/archive/2011/08/13/2137032.html Google 翻译 Box2d 托德的Box2D的教程! Bo ...
- iPhone Tutorials
http://www.raywenderlich.com/tutorials This site contains a ton of fun written tutorials – so many t ...
- A星寻路算法介绍
你是否在做一款游戏的时候想创造一些怪兽或者游戏主角,让它们移动到特定的位置,避开墙壁和障碍物呢? 如果是的话,请看这篇教程,我们会展示如何使用A星寻路算法来实现它! 在网上已经有很多篇关于A星寻路算法 ...
- A星寻路算法(A* Search Algorithm)
你是否在做一款游戏的时候想创造一些怪兽或者游戏主角,让它们移动到特定的位置,避开墙壁和障碍物呢? 如果是的话,请看这篇教程,我们会展示如何使用A星寻路算法来实现它! 在网上已经有很多篇关于A星寻路算法 ...
- A*算法介绍
你是否在做一款游戏的时候想创造一些怪兽或者游戏主角,让它们移动到特定的位置,避开墙壁和障碍物呢? 如果是的话,请看这篇教程,我们会展示如何使用A星寻路算法来实现它! 在网上已经有很多篇关于A星寻路算法 ...
- 如何用TexturePacker打包素材
如何用TexturePacker打包素材 TexturePacker是一个非常好用的图片素材打包工具,它能帮助你减少游戏的图片内存使用. 官方下载地址:http://www.codeandweb.co ...
- [转载]A星寻路算法介绍
转载自:http://www.raywenderlich.com/zh-hans/21503/a%E6%98%9F%E5%AF%BB%E8%B7%AF%E7%AE%97%E6%B3%95%E4%BB% ...
- iPhone开发与cocos2d 经验谈
转CSDN jilongliang : 首先,对于一个完全没有mac开发经验,甚至从没摸过苹果系统的开发人员来说,首先就是要熟悉apple的那一套开发框架(含开发环境IDE.开发框架uikit,还有开 ...
随机推荐
- c++右值引用
右值 右值是相对与左值来说的. 左值是以变量的形式存在,指向一个指定的内存,可以对它取地址.右值就是不指向任何地方,它是暂时和短命的,不能对它取地址. 右值引用 把临时的.生命周期短的值,绑定到一个变 ...
- C语言进阶——注释符号12
注释可能大认为非常简单,但是注释其实在C语言中很关键,来看下面一段对话. ---学生: 老师,我觉得注释没有必要深究,因为很简单,对程序功能也没有影响. ---老师: 注释是C语言最重要的工具,我们先 ...
- url_maneger.py
coding=UTF-8 # url管理器 class urlManeger: def __init__(self): self.new_urls = set() self.old_urls = se ...
- 2,版本控制git --分支
有人把 Git 的分支模型称为它的`‘必杀技特性’',也正因为这一特性,使得 Git 从众多版本控制系统中脱颖而出. 为何 Git 的分支模型如此出众呢? Git 处理分支的方式可谓是难以置信的轻量, ...
- MyBatis---简单关系查询
联合查询 <!-- 处理关系查询相关的复杂返回数据类型(本例中未曾用到) --> <resultMap type="SchoolStudent" id=" ...
- str_replace字符串替换
字符串替换, src 源字符串, buf_size 缓冲大小, search搜索的字符串大小, repstr 需要替换成的字符串 int str_replace(char *src, unsigned ...
- poj3348 Cows 凸包 叉积求多边形面积
graham扫描法,参考yyb #include <algorithm> #include <iostream> #include <cstdio> #includ ...
- The Django Book
The Django Book Table of contents 2.0, English -> Chinese Django book 2.0 的中文翻译. 最近更新 - 贡献者 方便自己也 ...
- grunt简记
grunt和gulp都是前端自动化的工具,grunt更成熟,插件社区全.大:gulp比较年轻,性能更好,更简单容易.具体使用哪种可根据实际项目组来决定. 创建任务 grunt默认执行的是default ...
- 《Cracking the Coding Interview》——第18章:难题——题目13
2014-04-29 04:40 题目:给定一个字母组成的矩阵,和一个包含一堆单词的词典.请从矩阵中找出一个最大的子矩阵,使得从左到右每一行,从上到下每一列组成的单词都包含在词典中. 解法:O(n^3 ...