ThirdPersonCameraCtrl.ts 826 B

12345678910111213141516171819202122
  1. import { _decorator, Component, Node } from 'cc';
  2. import { ThirdPersonCamera } from '../easy_camera/ThirdPersonCamera';
  3. import { EasyController, EasyControllerEvent } from './EasyController';
  4. const { ccclass, property } = _decorator;
  5. @ccclass('tgxThirdPersonCameraCtrl')
  6. export class ThirdPersonCameraCtrl extends ThirdPersonCamera {
  7. start() {
  8. EasyController.on(EasyControllerEvent.CAMERA_ROTATE, this.onCameraRotate, this);
  9. EasyController.on(EasyControllerEvent.CAMERA_ZOOM, this.onCameraZoom, this);
  10. this._targetLen = this.len;
  11. this._targetAngles.set(this.node.eulerAngles);
  12. }
  13. onDestroy() {
  14. EasyController.off(EasyControllerEvent.CAMERA_ROTATE, this.onCameraRotate, this);
  15. EasyController.off(EasyControllerEvent.CAMERA_ZOOM, this.onCameraZoom, this);
  16. }
  17. }