import { _decorator, Component, Node, input, Input, EventTouch, Collider, ITriggerEvent } from 'cc'; import { constant } from '../framework/constant'; const { ccclass, property } = _decorator; // 未使用 @ccclass('self_plane') export class self_plane extends Component { // @property // public speed = 1; start() { // input.on(Input.EventType.TOUCH_START, this._touchStart, this); // input.on(Input.EventType.TOUCH_MOVE, this._touchMove, this); } onEnable() { const collider = this.getComponent(Collider) collider.on('onTriggerEnter', this._onTriggerEnter, this) } onDisable() { const collider = this.getComponent(Collider) collider.off('onTriggerEnter', this._onTriggerEnter, this) } private _onTriggerEnter(event: ITriggerEvent) { console.log('玩家'); const collisionGroup = event.otherCollider.getGroup(); if (collisionGroup === constant.CollisionType.ENEMY_PLANE) { // 敌机或敌机子弹 console.log('reduce blood'); } } // update(deltaTime: number) { // } // _touchMove(event: EventTouch) { // const delta = event.getDelta(); // let pos = this.node.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.node.setPosition(pos.x + 0.01 * this.speed * delta.y, pos.y, pos.z + 0.01 * this.speed * delta.x) // } }