DoubleSpeedViewComp.ts 2.4 KB

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