UIClickEft.ts 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import { GameEvent } from "../../../data/const/EventConst";
  2. import { ViewZOrder } from "../../../data/const/ViewZOrder";
  3. import GameDataCenter from "../../../data/GameDataCenter";
  4. import ResSpine from "../../../frameWork/compment/ResSpine";
  5. import EventMng from "../../../manager/EventMng";
  6. const { ccclass, property } = cc._decorator;
  7. @ccclass
  8. export default class UIClickEft extends cc.Component {
  9. @property(ResSpine)
  10. clickResSpine: ResSpine = null;
  11. protected onEnable(): void {
  12. EventMng.on(GameEvent.ON_CLICK, this.onClick, this)
  13. }
  14. protected onDisable(): void {
  15. EventMng.off(GameEvent.ON_CLICK, this.onClick, this)
  16. }
  17. start() {
  18. cc.game.addPersistRootNode(this.node)
  19. this.node.zIndex = ViewZOrder.ClickEft;
  20. this.clickResSpine.setSpineData("spine", "effect_dianji01/effect_dianji01", null, false, "animation");
  21. this.clickResSpine.addCompleteListener(this.OnCompleteListener.bind(this));
  22. this.clickResSpine.node.active = false;
  23. }
  24. onClick(event) {
  25. GameDataCenter.time.guideRuoTime = 0
  26. if (this.clickResSpine == null) {
  27. return
  28. }
  29. this.clickResSpine.node.active = true;
  30. this.clickResSpine.node.x = event.getLocationX()
  31. this.clickResSpine.node.y = event.getLocationY()
  32. this.clickResSpine.playAnimation("animation", false);
  33. }
  34. OnCompleteListener() {
  35. this.clickResSpine.node.active = false;
  36. }
  37. }