123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- import DateTime from "../scripts/help/DateTime";
- const {ccclass, property} = cc._decorator;
- @ccclass
- export default class TickTest extends cc.Component {
-
- // LIFE-CYCLE CALLBACKS:
- // onLoad () {}
- public setTimeScale(touch,val){
- cc.director.getScheduler().setTimeScale(val);
- }
- public startTick(){
- Ticker.start(new Date().getTime());
- }
- public stopTick(){
- Ticker.stop();
- }
- public pause(){
- Ticker.pause();
- }
- public repause(){
- Ticker.resume();
- }
- private timerId: string;
- public startItv() {
- this.removeItv();
- this.timerId = Ticker.registerDelay(this.tick.bind(this), 1000);
- }
- private tick(count:number){
- console.log( DateTime.formatDate()+ " tick:"+count)
- }
- public removeItv() {
-
- Ticker.unregisterDelay(this.timerId);
- }
-
- // update (dt) {}
- }
|