import { _decorator, Component, EventTouch, Input, Node } from 'cc'; import { gameMangager } from '../framework/gameMangager'; const { ccclass, property } = _decorator; @ccclass('uiMain') export class uiMain extends Component { @property public planeSpeed = 1; @property(Node) public playerPlane: Node = null @property(gameMangager) public gamgeManager: gameMangager = null; start() { // input.on(Input.EventType.TOUCH_START, this._touchStart, this); this.node.on(Input.EventType.TOUCH_MOVE, this._touchMove, this); // this.node.on(Input.EventType.TOUCH_START, this._touchStart, this); this.node.on(Input.EventType.TOUCH_END, this._touchEnd, this); } // update(deltaTime: number) { // } _touchMove(event: EventTouch) { const delta = event.getDelta(); let pos = this.playerPlane.position; // x 上下, z 左右 // this.node.setPosition(pos.x - 0.01 * this.speed * delta.x, pos.y, pos.z - 0.01 * this.speed * delta.y) this.playerPlane.setPosition(pos.x + 0.01 * this.planeSpeed * delta.y, pos.y, pos.z + 0.01 * this.planeSpeed * delta.x) } _touchStart(event: EventTouch){ console.log('开始发射'); this.gamgeManager.isShooting(true) } _touchEnd(event: EventTouch){ console.log('结束发射'); this.gamgeManager.isShooting(false) } }