
import { _decorator, Component, Node, Event, SystemEvent, game, systemEvent, EventTouch, RigidBody, RigidBody2D, Vec2, Camera } from 'cc';
const { ccclass, property } = _decorator;

/**
 * Predefined variables
 * Name = Tank
 * DateTime = Wed Dec 22 2021 18:10:28 GMT+0800 (中国标准时间)
 * Author = Winterning
 * FileBasename = Tank.ts
 * FileBasenameNoExtension = Tank
 * URL = db://assets/Tank.ts
 * ManualUrl = https://docs.cocos.com/creator/3.3/manual/zh/
 *
 */

@ccclass('Tank')
export class Tank extends Component {
    // [1]
    // dummy = '';

    // [2]
    // @property({ type: Camera })
    // camera: Camera;

    start() {
        // [3]

        systemEvent.on(SystemEvent.EventType.TOUCH_START, this.onTouch, this);
        // console.log("@@start");
        // this.camera.node.position.set(this.node.position.x, this.node.position.y, 1000)
    }

    // update(deltaTime: number) {
    //     // [4]   
    // }

    private onTouch(touch, event): void {
        console.log("@@onTouch");
        var rig: RigidBody2D = this.getComponent(RigidBody2D);
        rig.applyForceToCenter(new Vec2(100, 0), true);
    }
}

/**
 * [1] Class member could be defined like this.
 * [2] Use `property` decorator if your want the member to be serializable.
 * [3] Your initialization goes here.
 * [4] Your update function goes here.
 *
 * Learn more about scripting: https://docs.cocos.com/creator/3.3/manual/zh/scripting/
 * Learn more about CCClass: https://docs.cocos.com/creator/3.3/manual/zh/scripting/ccclass.html
 * Learn more about life-cycle callbacks: https://docs.cocos.com/creator/3.3/manual/zh/scripting/life-cycle-callbacks.html
 */
