DemoViewComp.ts 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * @Author: mojunshou 1637302775@qq.com
  3. * @Date: 2025-02-26 17:11:55
  4. * @LastEditors: mojunshou 1637302775@qq.com
  5. * @LastEditTime: 2025-03-11 17:21:52
  6. * @FilePath: \Cocos_android\assets\script\game\account\view\DemoViewComp.ts
  7. * @Description: DemoView场景文件
  8. */
  9. import { _decorator } from "cc";
  10. import { ecs } from "../../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
  11. import { CCComp } from "../../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
  12. import { Label } from "cc";
  13. import { EventTouch } from "cc";
  14. import { oops } from "db://oops-framework/core/Oops";
  15. const { ccclass, property } = _decorator;
  16. /** 视图层对象 */
  17. @ccclass('DemoViewComp')
  18. @ecs.register('DemoView', false)
  19. export class DemoViewComp extends CCComp {
  20. start() {
  21. this.setButton();
  22. this.setEvent("onGlobal1", "onGlobal2");
  23. const Lb = this.getNode("textLb");
  24. console.log("Lb", Lb);
  25. const text = this.getNode("textLb")?.getComponent(Label);
  26. if (text) {
  27. text.string = "这是开始游戏的场景";
  28. }
  29. }
  30. private btn_simple(event: EventTouch) {
  31. oops.gui.toast("触发简单按钮触摸事件");
  32. oops.message.dispatchEvent("onGlobal1", "触发全局事件1");
  33. }
  34. private onGlobal1(event: string, args: any) {
  35. oops.gui.toast(args);
  36. };
  37. private onGlobal2(event: string, args: any) {
  38. oops.gui.toast(args);
  39. };
  40. reset() {
  41. this.node.destroy();
  42. }
  43. }