TouchMgr.ts 829 B

123456789101112131415161718192021222324252627282930
  1. import { _decorator, Component, EventTouch, Node, Vec2 } from 'cc';
  2. import { RoleList } from './RoleList';
  3. import { resMgr } from '../../Frames/ResourcesMgr';
  4. import { CharacterSlotMgr } from './CharacterSlotMgr';
  5. const { ccclass, property } = _decorator;
  6. @ccclass('TouchMgr')
  7. export class TouchMgr extends Component {
  8. movePos: Vec2 = null;
  9. protected onLoad(): void {
  10. }
  11. start() {
  12. this.node.on(Node.EventType.TOUCH_START, (e: EventTouch) => {
  13. //pos 为 世界坐标系下的坐标,以左下角为原点(0,0)
  14. const pos = e.getUILocation();
  15. this.func(pos);
  16. })
  17. this.node.on(Node.EventType.TOUCH_MOVE, (e: EventTouch) => {
  18. const pos = e.getUILocation();
  19. this.movePos = pos;
  20. })
  21. }
  22. func(pos: Vec2) {
  23. }
  24. }