CheckpointSkinViewComp.ts 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import { EventTouch, Node, Toggle, Tween, Vec3, _decorator, easing, tween } from "cc";
  2. import { oops } from "../../../../../extensions/oops-plugin-framework/assets/core/Oops";
  3. import { ecs } from "../../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
  4. import { CCComp } from "../../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
  5. import { UIID } from "../../common/config/GameUIConfig";
  6. import { SingletonModuleComp } from "../../common/SingletonModuleComp";
  7. import { CheckpointSkinItemViewComp } from "./CheckpointSkinItem";
  8. const { ccclass, property } = _decorator;
  9. /** 角色换装界面 */
  10. @ccclass('CheckpointSkinViewComp')
  11. @ecs.register('CheckpointSkinView', false)
  12. export class CheckpointSkinViewComp extends CCComp {
  13. @property({ type: [CheckpointSkinItemViewComp], visible: true, tooltip: '关卡item' })
  14. itemArr: Array<CheckpointSkinItemViewComp> = []
  15. private btnClose
  16. onAdded(args: any) {
  17. console.log(args);
  18. }
  19. onLoad() {
  20. this.btnClose = this.node.getChildByPath("BG/btn_close")
  21. this.btnClose.on(Node.EventType.TOUCH_END, this.onTouchEnd, this);
  22. const window = this.node.getChildByName("BG")
  23. window.setScale(new Vec3(0, 0, 1));
  24. // 使用Tween来实现动画效果
  25. Tween.stopAllByTarget(window); // 停止该节点上的所有其他Tween
  26. tween(window)
  27. // .delay(0.1)
  28. .to(0.3, { scale: new Vec3(0.5, 0.5, 1) }, { easing: easing.backOut }) // 缩放动画
  29. .start(); // 开始动画
  30. }
  31. private onTouchEnd(event: EventTouch) {
  32. switch (event.target.name) {
  33. case "btn_close":
  34. oops.gui.remove(UIID.Skin);
  35. break;
  36. }
  37. event.propagationStopped = true;
  38. }
  39. reset() {
  40. this.node.destroy();
  41. }
  42. }