Cocos2D-X定时器selector的使用
来源:互联网 发布:ucloud域名备案 编辑:程序博客网 时间:2024/04/28 02:09
在游戏设计时,我们需要不断的改变屏幕显示来反映游戏操作的效果,最简单的就是提示用户已经进行的游戏时间。为此,我们需要使用cocos2d-x内置的任务调度机制,即CCNode的schedule成员函数。
void
schedule (SEL_SCHEDULE selector)
schedules a selector.
void
schedule (SEL_SCHEDULE selector, ccTime interval)
schedules a custom selector with an interval time in seconds.
void
unschedule (SEL_SCHEDULE selector)
unschedules a custom selector.
void
unscheduleAllSelectors (void)
unschedule all scheduled selectors: custom selectors, and the 'update' selector.
Cocos2D-X中的schedule有两种作用:
1)定时执行方法
例如,每隔1秒就执行GameLayer类的方法step(ccTime dt)。
this->schedule(schedule_selector(GameLayer::step), 1.0f);
...
void GameLayer::step(ccTime dt)
{
...
}
2)延时执行方法
例如, 延时 5秒执行GameLayer类的方法step(ccTime dt)。
this->schedule(schedule_selector(GameLayer::step), 5.0f);
...
void GameLayer::step(ccTime dt)
{
this->unschedule(schedule_selector( GameLayer::step ));
...
}
- Cocos2D-X定时器selector的使用
- Cocos2D-X@定时器selector的使用(…
- cocos2d-x 定时器selector的使用 :schedule的使用
- cocos2d-x 定时器selector的使用 :schedule的使用
- cocos2d-x 定时器selector的使用 :schedule的使用
- cocos2d-x中定时器的使用
- cocos2d-x的定时器
- Cocos2d-x lua 使用定时器
- Cocos2d-x定时器使用汇总
- Cocos2d-x 定时器的浅析
- cocos2d-x的定时器分析
- Cocos2d-x 定时器的浅析
- Cocos2d-x 定时器的浅析
- Cocos2d-x 定时器的浅析
- Cocos2d-x三种定时器的使用schedule,scheduleUpdate,scheduleOnce
- cocos2d-x之三种定时器的使用
- 关于Cocos2d-x中定时器的使用总结
- 【深入了解cocos2d-x 3.x】定时器(scheduler)的使用和原理探究(1)
- 软件测试技能鉴定(模拟题)___含答案
- Poj 1650 & Zoj 1601 Integer Approximation (追赶法,分数逼近实数)
- Lync 2010升级到Lync 2013 之边缘服务器的部署!
- 网络子系统57_路由Scope
- pl/sql 游标变量实例
- Cocos2D-X定时器selector的使用
- cocos2d-x在windows平台HelloWorld解析系列二
- SSH全注解整合开发环境安装配置 v1.0.BETA
- IOS ScrollView 左右滑动(或者上下滑动)支持其中一种
- 消灭兔子-贪心
- 高质量编程(二)
- PostgreSQL
- bat的使用
- IOS中比较位置