import { director, Node, Component } from "cc"; import { DateDataProxy } from "../Mgr_LocalData/DataTypeProxy/DateDataProxy"; export default class LoopMgr extends Component { private static _ins:LoopMgr = null; static get ins():LoopMgr{ if(!this._ins){ let tNdoe = new Node("LoopMgr") director.getScene().addChild(tNdoe); tNdoe.addComponent(LoopMgr); } return this._ins; } protected onLoad() { if (LoopMgr._ins != null) { this.node.destroy(); return; } LoopMgr._ins = this.node.getComponent(LoopMgr); //不允许销毁 director.addPersistRootNode(this.node) this.init(); } protected onDestroy(): void { LoopMgr._ins = null; } protected start(): void { this.schedule(this.SecondTick, 1.0); } init(){ } /**每秒执行 */ SecondTick() { DateDataProxy.Ins.addOnlineTime(1); } } window["LoopMgr"] = LoopMgr;