import { _decorator, Component, Node, Vec3, director, CameraComponent } from 'cc'; const { ccclass, property } = _decorator; @ccclass('CameraUtils') export class CameraUtils extends Component { /* class member could be defined like this */ // dummy = ''; /* use `property` decorator if your want the member to be serializable */ // @property // serializableDummy = 0; private min:Vec3; private max:Vec3; private out:Vec3=new Vec3(); private startTime:number; private endTime:number; private startPos:Vec3=new Vec3(); private shakeing:boolean; private camera:CameraComponent; /** * 抖动 * @param time 持续时间 * @param min 最小值 * @param max 最大值 */ shake(time:number,min:Vec3,max:Vec3):void{ this.min=min; this.max=max; this.startTime=director.getCurrentTime(); this.endTime=this.startTime+time; this.shakeing=true; this.startPos.set(this.node.position.x,this.node.position.y,this.node.position.z); this.camera=this.node.getComponent(CameraComponent); } start () { // Your initialization goes here. } update (deltaTime: number) { if(this.shakeing){ let currentTime:number=director.getCurrentTime(); if(currentTime