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内核有什么区别? 什么是引导装载程序 ...
随机推荐
- BZOJ 3747 POI2015 Kinoman 段树
标题效果:有m点,每个点都有一个权值.现在我们有这个m为点的长度n该序列,寻求区间,它仅出现一次在正确的点区间内值和最大 想了很久,甚至神标题,奔说是水的问题--我醉了 枚举左点 对于每个请求留点右键 ...
- (一个)kafka-jstorm集群实时日志分析 它 ---------kafka实时日志处理
package com.doctor.logbackextend; import java.util.HashMap; import java.util.List; import java.util. ...
- OCP-1Z0-051-题目解析-第14题
14. Using the CUSTOMERS table, you need to generate a report that shows 50% of each credit a ...
- 计算机管理系统——VB与Excel联系
今天爆震室管理系统--学生查看机器状态的时候发现有一个"导出到excel"的button.我去.感情还得跟excel表链接. 于是我咬碎了一地小银牙.一个下午都在查询vb与exce ...
- sqlserver 无法初始化via支持库[QLVIPL.DLL]
安装数据库后,在sqlserver configuration manager, sqlserver的网络配置,有将协议 shared memory,named pipes,tcp/ip,via全部启 ...
- php 二维数组传递给 js 问题解决记录
需求: php从数据库中读取到二维数组.传递到js中 实现步骤: php:json_encode → json → js:eval 即在php中使用json_encode()将php的二维数 ...
- 开始的iOS编程之前的准备
原地址:http://www.appcoda.com/what-you-need-to-begin-ios-programming/ 1.准备一台苹果设备 这段基本是废话,我就不翻译了,IOS开发你懂 ...
- Unit of Work
ABP使用及框架解析系列 - [Unit of Work part.2-框架实现] 前言 ABP ABP是“ASP.NET Boilerplate Project”的简称. ABP的官方网站:ht ...
- SynchronousQueue、LinkedBlockingQueue、ArrayBlockingQueue性能测试(转)
听说JDK6对SynchronousQueue做了性能优化,避免对竞争资源加锁,所以想试试到底平时是选择SynchronousQueue还是其他BlockingQueue. 对于容器类在并发环境下的比 ...
- Android 应用程序窗口显示状态操作(requestWindowFeature()的应用)
我们在开发程序是常常会须要软件全屏显示.自己定义标题(使用button等控件)和其它的需求,今天这一讲就是怎样控制Android应用程序的窗口显示. 首先介绍一个重要方法那就是requestWi ...