TapNode.ts 825 B

12345678910111213141516171819202122232425262728293031
  1. import gameUI from "./gameUI";
  2. import towerManger from ".././tower/towerManger";
  3. import viewComtent from "./viewComtent";
  4. const {ccclass, property} = cc._decorator;
  5. @ccclass
  6. export default class TapNode extends cc.Component {
  7. public static instance:TapNode = null;
  8. protected onLoad () {
  9. TapNode.instance = this;
  10. this.node.active = false;
  11. this.node.on(cc.Node.EventType.TOUCH_START, this.onTouchStart, this);
  12. }
  13. /**
  14. * touchstart 回调
  15. * @param e 参数
  16. */
  17. private onTouchStart(e: cc.Event.EventTouch): void {
  18. let turnPos = e.getLocation().sub(cc.v2(960,540));
  19. towerManger.instance.chaqiGetPos(turnPos.add(cc.v2(0,viewComtent.instance.getOff())));
  20. gameUI.instance.SkillTap(turnPos.add(cc.v2(0,viewComtent.instance.getOff())));
  21. }
  22. }