cocos2d-x游戏开发(七)对象释放时机
来源:互联网 发布:kali linux 2.0官方源 编辑:程序博客网 时间:2024/05/21 17:52
欢迎转载:http://blog.csdn.net/fylz1125/article/details/8521272
这篇写写自动对象的释放时机。
一个对象调用autorelease()函数后就被加入自动释放池,那么它什么时候被释放呢?
我从前面说过的游戏主循环开始跟进:
- int CCApplication::run()
- {
- if (applicationDidFinishLaunching())
- {
- [[CCDirectorCaller sharedDirectorCaller] startMainLoop];//主循环开始
- }
- return 0;
- }
继续跟进startMainLoop函数
- -(void) startMainLoop
- {
- // CCDirector::setAnimationInterval() is called, we should invalidate it first
- [displayLink invalidate];
- displayLink = nil;
- // displayLink是CADisplayLink对象,target是自己,回调是coCaller
- displayLink = [NSClassFromString(@"CADisplayLink") displayLinkWithTarget:self selector:@selector(doCaller:)];//看这个doCaller回调
- [displayLink setFrameInterval: self.interval];//设置帧率
- [displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];//添加到循环并启动
- }
看doCaller回调,
- void CCDisplayLinkDirector::mainLoop(void)
- {
- if (m_bPurgeDirecotorInNextLoop)
- {
- m_bPurgeDirecotorInNextLoop = false;
- purgeDirector();
- }
- else if (! m_bInvalid)
- {
- drawScene();// draw the scene
- // release the objects
- CCPoolManager::sharedPoolManager()->pop();
- }
- }
这里就释放对象了,有兴趣的同学可以自己跟进去看看到底是怎么释放的。
0 0
- cocos2d-x游戏开发(七)对象释放时机
- cocos2d-x游戏开发(七)对象释放时机
- cocos2d-x游戏开发(七)对象释放时机
- cocos2d-x游戏开发(五)神奇的自动释放
- cocos2d-x游戏开发(六)自动释放池
- cocos2d-x游戏开发(五)神奇的自动释放
- cocos2d-x游戏开发(六)自动释放池
- cocos2d-x游戏开发(五)神奇的自动释放
- cocos2d-x游戏开发(六)自动释放池
- Cocos2d-X游戏开发之Json解析(七)
- cocos2d-x游戏开发 跑酷(七) 添加金币和岩石
- cocos2d-x游戏开发 跑酷(七) 添加金币和岩石
- cocos2d-x游戏开发
- cocos2d-x游戏开发 跑酷(八) 对象管理 碰撞检测
- cocos2d-x游戏开发 跑酷(八) 对象管理 碰撞检测
- Cocos2d-x Lua游戏开发之Lua 面向对象编程
- cocos2d-x游戏开发详解
- COCOS2D-X游戏开发常用工具
- Handler 理解
- 四种不同的内部类的应用范畴
- cocos2d-x游戏开发(六)自动释放池
- 微信公众帐号开发教程第13篇-图文消息全攻略
- PHP文件操作(文件移动和复制、删除、重命名)
- cocos2d-x游戏开发(七)对象释放时机
- hadoop大事件
- mac 终端 常用命令
- cocos2d-x游戏开发(八)各类构造器
- spring作用
- ViewPager的使用方法
- cocos2d-x游戏开发(九)重要的基类CCNode
- Android 图片处理 常用代码快
- OpenCV LDA(Linnear Discriminant analysis)类的使用---OpenCV LDA示例