DoubleSpeedViewComp.ts 2.4 KB

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