cocos2dx 解释二具体的启动过程:内存管理和回调
void CCDirector::drawScene(void)
{
…...
//tick before glClear: issue #533
if (! m_bPaused) //暂停
{
m_pScheduler->update(m_fDeltaTime); //待会会解释这里的内容
}
@since v2.0
*/
CC_PROPERTY(CCScheduler*, m_pScheduler, Scheduler);
We can use getter to read the variable, and use the setter to change the variable.
@param varType : the type of variable.
@param varName : variable name.
@param funName : "get + funName" is the name of the getter.
"set + funName" is the name of the setter.
@warning : The getter and setter are public virtual functions, you should rewrite them first.
The variables and methods declared after CC_PROPERTY are all public.
If you need protected or private, please declare.
*/
#define CC_PROPERTY(varType, varName, funName)\
protected: varType varName;\
public: virtual varType get##funName(void);\
public: virtual void set##funName(varType var);
void CCScheduler::update(float dt)
// The 'timers' array may change while inside this loop
for (elt->timerIndex = 0; elt->timerIndex < elt->timers->num; ++(elt->timerIndex))
{
elt->currentTimer = (CCTimer*)(elt->timers->arr[elt->timerIndex]);
elt->currentTimerSalvaged = false;
elt->currentTimer->update(dt); //这里又有一个update函数哟
if (elt->currentTimerSalvaged)
{
// The currentTimer told the remove itself. To prevent the timer from
// accidentally deallocating itself before finishing its step, we retained
// it. Now that step is done, it's safe to release it.
elt->currentTimer->release();
}
elt->currentTimer = NULL;
}
{
…..
if (m_bRunForever && !m_bUseDelay)
{//standard timer usage
m_fElapsed += dt;
if (m_fElapsed >= m_fInterval)
{
if (m_pTarget && m_pfnSelector)
{
(m_pTarget->*m_pfnSelector)(m_fElapsed); //第一个出现了
}
…..
if( m_fElapsed >= m_fDelay )
{
if (m_pTarget && m_pfnSelector)
{
(m_pTarget->*m_pfnSelector)(m_fElapsed); //第二个出现了
}
……..
else
{
if (m_fElapsed >= m_fInterval)
{
if (m_pTarget && m_pfnSelector)
{
(m_pTarget->*m_pfnSelector)(m_fElapsed); //第三个出现了
}
……..
}
{
this->schedule(selector, interval, kCCRepeatForever, 0.0f);
}
void CCNode::schedule(SEL_SCHEDULE selector, float interval, unsigned int repeat, float delay)
{
CCAssert( selector, "Argument must be non-nil");
CCAssert( interval >=0, "Argument must be positive");
m_pScheduler->scheduleSelector(selector, this, interval , repeat, delay, !m_bRunning);
}
{
。。。。。
。
CCTimer *pTimer = new CCTimer();
pTimer->initWithTarget(pTarget, pfnSelector, fInterval, repeat, delay); //看这里
ccArrayAppendObject(pElement->timers, pTimer);
pTimer->release();
}
{
m_pTarget = pTarget;
。。
。。
return true;
}
也就是说pTarget是CCNode对象。
版权声明:本文博主原创文章,博客,未经同意不得转载。
cocos2dx 解释二具体的启动过程:内存管理和回调的更多相关文章
- linux源码分析(二)-启动过程
前置:这里使用的linux版本是4.8,x86体系. 这篇是 http://home.ustc.edu.cn/~boj/courses/linux_kernel/1_boot.html 的学习笔记. ...
- Angular总结二:Angular 启动过程
要弄清楚 Angular 的启动过程,就要弄明白 Angular 启动时加载了哪个页面,加载了哪些脚本,这些脚本做了哪些事? 通过 Angular 的编译依赖文件 .angular-cli.json ...
- (二)SpringBoot启动过程的分析-环境信息准备
-- 以下内容均基于2.1.8.RELEASE版本 由上一篇SpringBoot基本启动过程的分析可以发现在run方法内部启动SpringBoot应用时采用多个步骤来实现,本文记录启动的第二个环节:环 ...
- 【cocos2d-x 3.x 学习笔记】对象内存管理
内存管理 内存管理一直是一个不易处理的问题.开发人员必须考虑分配回收的方式和时机,针对堆和栈做不同的优化处理,等等.内存管理的核心是动态分配的对象必须保证在使用完成后有效地释放内存,即管理对象的生命周 ...
- 二、Linux文件系统之内存管理
虚拟内存 32位:4G 64位:2^64 内存管理: 进程管理 自动分配和管理 支持模块化程序设计 保护和访问控制 长期存储 虚拟内存 <---MMU-->物理内存
- LinearLayout具体解释二:LinearLayout的创建过程以及状态全程解析
正在撰稿中,请稍等...
- springboot启动过程中常用的回调
1.介绍 springboot提供非常丰富回调接口,利用这些接口可以做非常多的事情,对于一些常用的回调接口进行介绍 2.常用的拓展接口 1.ApplicationContextInitializer ...
- Android(java)学习笔记162:Android启动过程(转载)
转载路径为: http://blog.jobbole.com/67931/ 1. 关于Android启动过程的问题: 当按下Android设备电源键时究竟发生了什么? Android的启动过程是怎么样 ...
- Android程序启动过程深入解析
当按下Android设备电源键时究竟发生了什么? Android的启动过程是怎么样的? 什么是Linux内核? 桌面系统linux内核与Android系统linux内核有什么区别? 什么是引导装载程序 ...
随机推荐
- 玩转Web之servlet(四)---B/S是如何使用http协议完成通信过程的
在上一篇文章中,我简单的说了一下B/S架构的流程图,关于浏览器和服务器之间的通信过程知识含糊的说了一下,在这篇文章中我再总结一下B/S架构里是如何利用http协议去完成通信的. (一)通讯过程 1:浏 ...
- wamp无法登录phpmyadmin问题
文章来源:PHP座谈会 地址:http://bbs.phpthinking.com/forum.php? mod=viewthread&tid=163 第一步.用navicat确认一下,自己的 ...
- nodejs添加路由route步骤详解
首先,毋庸置疑, 新建一个基础express站点.建好之后, 有三个文件需要code(当然,三个步骤顺序随意). 下面以添加一个'/about'为例说明. 1. 在views文件夹里,新建一个jade ...
- OCP解决问题052-- DROP PROFILE app_user
133.You created a profile APP_USER and assigned it to the users. After a month, you decide to drop t ...
- nginx lua redis 访问频率限制(转)
1. 需求分析 Nginx来处理访问控制的方法有多种,实现的效果也有多种,访问IP段,访问内容限制,访问频率限制等. 用Nginx+Lua+Redis来做访问限制主要是考虑到高并发环境下快速访问控制的 ...
- [LeetCode328]Odd Even Linked List
题目: Given a singly linked list, group all odd nodes together followed by the even nodes. Please note ...
- 什么是PV,UV。
PV浏览(Page View).该网页访问量,每次页面打开PV统计+1,也刷新. IP接入号码指独立IP接入号码,计算基于独立IP在计算的时间段来计算访问我们的网站1二级IP接入号码. 是否这个计算在 ...
- 花生壳宣布网站的网址直接绑定到详细的项目——jboss版本
花生壳公布,首先要有域名.然后激活域名,详细的公布就不说了,网上有非常多资料,这里是在jboss下直接将网址与详细的项目相应.做法有点不地道 假设跟图上一样配置的话.訪问网址相当于訪问的是http:/ ...
- JAVA Socket传输Object(对象)注意的问题
在java中,可以通过socket将一个对象进行传递,通过ObjectOutputStream,ObjectInputStream来进行写入和读取(具体的方法参考http://blog.csdn.ne ...
- PHP于DIRECTORY_SEPARATOR任务
DIRECTORY_SEPARATOR是php的内部常量.用于显示系统分隔符的命令,不须要不论什么定义与包括就可以直接使用. 在windows下路径分隔符是\(当然/在部分系统上也是能够正常执行的), ...