/* * @Author: mojunshou 1637302775@qq.com * @Date: 2025-03-21 11:17:22 * @LastEditors: mojunshou 1637302775@qq.com * @LastEditTime: 2025-04-02 18:13:24 * @Description: 二倍速弹窗 */ import { _decorator, Node } from "cc"; import { oops } from "db://oops-framework/core/Oops"; import { ecs } from "db://oops-framework/libs/ecs/ECS"; import { CCComp } from "db://oops-framework/module/common/CCComp"; import { UIID } from "../../common/config/GameUIConfig"; import { Label } from "cc"; import { RichText } from "cc"; import { UICallbacks } from "db://oops-framework/core/gui/layer/Defines"; const { ccclass, property } = _decorator; /** 视图层对象 */ @ccclass('DoubleSpeedViewComp') @ecs.register('DoubleSpeedView', false) export class DoubleSpeedViewComp extends CCComp { /** 视图层逻辑代码分离演示 */ @property({ type: Label, displayName: "标题" }) private lab_title: Label = null!; @property({ type: Label, displayName: "倒数时间" }) private lab_time: Label = null!; @property({ type: RichText, displayName: "倒数时间" }) private rich_tips: RichText = null!; private _isAutoOpen: boolean = false; //是否倒数三秒自动开始 private _time: number = 3; start() { // const entity = this.ent as ecs.Entity; // ecs.Entity 可转为当前模块的具体实体对象 this.setButton(); } /** 视图对象通过 ecs.Entity.remove(DoubleSpeedViewComp) 删除组件是触发组件处理自定义释放逻辑 */ reset() { this.node.destroy(); } private updateInfo() { this.lab_title.string = this._isAutoOpen ? "二倍速" : "是否继续"; this.rich_tips.string = this._isAutoOpen ? "是否需要开启2倍智能放置?每看一个视频,可享受3分钟的二倍速放置哦" : "2倍速智能放置已经结束,是否继续开启?"; this.lab_time.node.active = this._isAutoOpen; //倒数三秒 this.scheduleOnce(() => { //播放广告 this.openAd(); this._isAutoOpen = false; }, 3); } private btn_open() { this.openAd(); oops.gui.remove(UIID.DoubleSpeed); } //打开广告 private openAd() { } private btn_close() { oops.gui.remove(UIID.DoubleSpeed); //播放插屏广告 } }