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