定时器
来源:互联网 发布:珠江钢琴天猫淘宝 编辑:程序博客网 时间:2024/06/02 02:00
/**
* Created by Administrator on 2017/4/21.
*/
var TestLayer = cc.Layer.extend({
ctor:function(){
/***********************scheduleUpdate系统定时器***********************/
this.scheduleUpdate();//调用update函数
/***********************schedule自定义定时器***********************/
this.schedule(this.updateData.bind(this),1,cc.REPEAT_FOREVER,0.1,"");
/***********************scheduleOnce只调用一次定时器***********************/
this.scheduleOnce(this.updateD.bind(this),0.1,"");
/***********************获取当前的时间***********************/
setTimeout(function(){
trace("pause", this.currentTime());
this.pause();
}.bind(this), 2000);
setTimeout(function(){
trace("resume", this.currentTime());
this.resume();
}.bind(this), 5000);
},
update: function (dt) {
//每0.02s调用一次
},
updateData: function () {
//会根据this.schedule第二个参数的时间来调用updataData函数
},
updateD: function () {
//只调用一次
},
currentTime: function () {
return parseInt(new Date().getTime()/1000);
}
});
* Created by Administrator on 2017/4/21.
*/
var TestLayer = cc.Layer.extend({
ctor:function(){
/***********************scheduleUpdate系统定时器***********************/
this.scheduleUpdate();//调用update函数
/***********************schedule自定义定时器***********************/
this.schedule(this.updateData.bind(this),1,cc.REPEAT_FOREVER,0.1,"");
/***********************scheduleOnce只调用一次定时器***********************/
this.scheduleOnce(this.updateD.bind(this),0.1,"");
/***********************获取当前的时间***********************/
setTimeout(function(){
trace("pause", this.currentTime());
this.pause();
}.bind(this), 2000);
setTimeout(function(){
trace("resume", this.currentTime());
this.resume();
}.bind(this), 5000);
},
update: function (dt) {
//每0.02s调用一次
},
updateData: function () {
//会根据this.schedule第二个参数的时间来调用updataData函数
},
updateD: function () {
//只调用一次
},
currentTime: function () {
return parseInt(new Date().getTime()/1000);
}
});
阅读全文
0 0
- 定时器
- 定时器
- 定时器
- 定时器
- 定时器
- 定时器
- 定时器
- 定时器
- 定时器
- 定时器
- 定时器
- 定时器
- 定时器
- 定时器
- 定时器
- 定时器
- 定时器
- 定时器
- 场景Scene
- AirBook GTI电脑这么厉害,竟然有数据恢复的功能?
- div下js失效的问题
- VC++:创建,调用Win32动态链接库
- timeline,一个简单精美的自定义时间轴
- 定时器
- 前端基于vue的分页
- Centos 7 右上角面板里没有wired network图标的问题
- linux下的python
- 实现UISearchBar的Placeholder居左显示
- 提高工作效率的几个chrome插件
- React简介
- PHP中COOKIE及时生效,不用刷新就可以使用
- docker for windows 设置aliyun加速以及改变pull镜像位置