PuppetViewComp.ts 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import { _decorator } from "cc";
  2. import { CCComp } from "../../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
  3. import { ecs } from "../../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
  4. import { PuppetViewController } from "./PuppetViewController";
  5. import { Puppet } from "../puppet";
  6. const { ccclass, property } = _decorator;
  7. /** 关卡显示组件 */
  8. @ccclass('PuppetViewComp') // 定义为 Cocos Creator 组件
  9. @ecs.register('PuppetView', false) // 定义为 ECS 组件
  10. export class PuppetViewComp extends CCComp {
  11. // /** 角色动画资源管理 */
  12. // loader: RoleViewLoader = null!;
  13. // /** 角色动画规则管理 */
  14. // animator: RoleViewAnimator = null!;
  15. /** 角色控制器 */
  16. controller: PuppetViewController = null!;
  17. /** 视图层逻辑代码分离演示 */
  18. onLoad() {
  19. const puppet = this.ent as Puppet;
  20. // this.loader = this.node.addComponent(RoleViewLoader);
  21. // this.node.emit("load", role);
  22. // this.animator = this.spine.getComponent(RoleViewAnimator)!;
  23. // this.animator.role = role;
  24. this.controller = this.node.addComponent(PuppetViewController);
  25. this.controller.puppet = puppet;
  26. // this.on(RoleEvent.ChangeJob, this.onHandler, this);
  27. }
  28. // /** 业务层全局消息通知视图层逻辑处理,两层之间逻辑解耦合演示 */
  29. // private onHandler(event: string, args: any) {
  30. // switch (event) {
  31. // case RoleEvent.ChangeJob:
  32. // this.animator.refresh();
  33. // break;
  34. // }
  35. // }
  36. reset() {
  37. this.node.destroy();
  38. }
  39. }