DoubleSpeedViewComp.ts 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * @Author: mojunshou 1637302775@qq.com
  3. * @Date: 2025-03-21 11:17:22
  4. * @LastEditors: mojunshou 1637302775@qq.com
  5. * @LastEditTime: 2025-04-02 18:13:24
  6. * @Description: 二倍速弹窗
  7. */
  8. import { _decorator, Node } from "cc";
  9. import { oops } from "db://oops-framework/core/Oops";
  10. import { ecs } from "db://oops-framework/libs/ecs/ECS";
  11. import { CCComp } from "db://oops-framework/module/common/CCComp";
  12. import { UIID } from "../../common/config/GameUIConfig";
  13. import { Label } from "cc";
  14. import { RichText } from "cc";
  15. import { UICallbacks } from "db://oops-framework/core/gui/layer/Defines";
  16. const { ccclass, property } = _decorator;
  17. /** 视图层对象 */
  18. @ccclass('DoubleSpeedViewComp')
  19. @ecs.register('DoubleSpeedView', false)
  20. export class DoubleSpeedViewComp extends CCComp {
  21. /** 视图层逻辑代码分离演示 */
  22. @property({ type: Label, displayName: "标题" })
  23. private lab_title: Label = null!;
  24. @property({ type: Label, displayName: "倒数时间" })
  25. private lab_time: Label = null!;
  26. @property({ type: RichText, displayName: "倒数时间" })
  27. private rich_tips: RichText = null!;
  28. private _isAutoOpen: boolean = false; //是否倒数三秒自动开始
  29. private _time: number = 3;
  30. start() {
  31. // const entity = this.ent as ecs.Entity; // ecs.Entity 可转为当前模块的具体实体对象
  32. this.setButton();
  33. }
  34. /** 视图对象通过 ecs.Entity.remove(DoubleSpeedViewComp) 删除组件是触发组件处理自定义释放逻辑 */
  35. reset() {
  36. this.node.destroy();
  37. }
  38. private updateInfo() {
  39. this.lab_title.string = this._isAutoOpen ? "二倍速" : "是否继续";
  40. this.rich_tips.string = this._isAutoOpen ? "是否需要开启2倍智能放置?每看一个视频,可享受3分钟的二倍速放置哦" : "2倍速智能放置已经结束,是否继续开启?";
  41. this.lab_time.node.active = this._isAutoOpen;
  42. //倒数三秒
  43. this.scheduleOnce(() => {
  44. //播放广告
  45. this.openAd();
  46. this._isAutoOpen = false;
  47. }, 3);
  48. }
  49. private btn_open() {
  50. this.openAd();
  51. oops.gui.remove(UIID.DoubleSpeed);
  52. }
  53. //打开广告
  54. private openAd() {
  55. }
  56. private btn_close() {
  57. oops.gui.remove(UIID.DoubleSpeed);
  58. //播放插屏广告
  59. }
  60. }