123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- System.register(["cc"], function (_export, _context) {
- "use strict";
- var _cclegacy, Timer, _crd;
- function get_new_timer(step) {
- return new Timer(step);
- }
- _export("default", get_new_timer);
- return {
- setters: [function (_cc) {
- _cclegacy = _cc.cclegacy;
- }],
- execute: function () {
- _crd = true;
- _cclegacy._RF.push({}, "890248SdzRIsa6dPHIO+Qxy", "Timer", undefined);
- Timer = class Timer {
- get elapsedTime() {
- return this._elapsedTime;
- }
- /** 触发间隔时间(秒) */
- get step() {
- return this._step;
- }
- set step(step) {
- this._step = step; // 每次修改时间
- this._elapsedTime = 0; // 逝去时间
- }
- get coundown() {
- return this._step - this._elapsedTime;
- }
- get progress() {
- return this._elapsedTime / this._step;
- }
- constructor(step) {
- if (step === void 0) {
- step = 0;
- }
- this._elapsedTime = 0;
- this._step = -1;
- this.step = step;
- }
- /**
- * 序列化(数据库存储)
- */
- serialize() {
- var data = {
- "step": this._step,
- "elapsed": this._elapsedTime
- };
- return data;
- }
- /**
- * 反序列化
- */
- unserialize(data) {
- if (!data) return;
- this._step = data.step;
- this._elapsedTime = data.elapsed;
- }
- update(dt) {
- if (this.step <= 0) return false;
- this._elapsedTime += dt;
- if (this._elapsedTime >= this._step) {
- this._elapsedTime -= this._step;
- return true;
- }
- return false;
- }
- reset() {
- this._elapsedTime = 0;
- }
- stop() {
- this._elapsedTime = 0;
- this.step = -1;
- }
- };
- _cclegacy._RF.pop();
- _crd = false;
- }
- };
- });
- //# sourceMappingURL=db8aefcd4ca5f0eb533739e806f9c0f865db70b3.js.map
|