import { _decorator, Component, EventTouch, Input, Node } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('uiMain')
export class uiMain extends Component {
    @property
    public planeSpeed = 1;


    @property(Node)
    public playerPlane: Node = null

    start() {
        // input.on(Input.EventType.TOUCH_START, this._touchStart, this);
        this.node.on(Input.EventType.TOUCH_MOVE, this._touchMove, 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)
    }
}


