/* * @Author: mojunshou 1637302775@qq.com * @Date: 2025-02-26 17:11:55 * @LastEditors: mojunshou 1637302775@qq.com * @LastEditTime: 2025-03-11 17:21:52 * @FilePath: \Cocos_android\assets\script\game\account\view\DemoViewComp.ts * @Description: DemoView场景文件 */ import { _decorator } from "cc"; import { ecs } from "../../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS"; import { CCComp } from "../../../../../extensions/oops-plugin-framework/assets/module/common/CCComp"; import { Label } from "cc"; import { EventTouch } from "cc"; import { oops } from "db://oops-framework/core/Oops"; const { ccclass, property } = _decorator; /** 视图层对象 */ @ccclass('DemoViewComp') @ecs.register('DemoView', false) export class DemoViewComp extends CCComp { start() { this.setButton(); this.setEvent("onGlobal1", "onGlobal2"); const Lb = this.getNode("textLb"); console.log("Lb", Lb); const text = this.getNode("textLb")?.getComponent(Label); if (text) { text.string = "这是开始游戏的场景"; } } private btn_simple(event: EventTouch) { oops.gui.toast("触发简单按钮触摸事件"); oops.message.dispatchEvent("onGlobal1", "触发全局事件1"); } private onGlobal1(event: string, args: any) { oops.gui.toast(args); }; private onGlobal2(event: string, args: any) { oops.gui.toast(args); }; reset() { this.node.destroy(); } }