Browse Source

摄像机抖动

greg 4 năm trước cách đây
mục cha
commit
7a9cfbba10

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 148 - 135
assets/resources/scenes/FightingScene.scene


+ 6 - 1
assets/scripts/engines/utils/CameraUtils.ts

@@ -11,7 +11,7 @@ export class CameraUtils extends Component {
     // serializableDummy = 0;
     private min:Vec3;
     private max:Vec3;
-    private out:Vec3;
+    private out:Vec3=new Vec3();
 
     private startTime:number;
     private endTime:number;
@@ -27,6 +27,8 @@ export class CameraUtils extends Component {
      * @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;
@@ -43,6 +45,9 @@ export class CameraUtils extends Component {
             let currentTime:number=director.getCurrentTime();
             if(currentTime<this.endTime){
                 this.randomV3(this.min,this.max,this.out);
+                this.out.x+=this.startPos.x;
+                this.out.y+=this.startPos.y;
+                this.out.z+=this.startPos.z;
                 this.node.position=this.out;
             }else{
                 this.node.position=this.startPos;

+ 1 - 1
assets/scripts/games/ui/fightings/GameController.ts

@@ -316,7 +316,7 @@ export class GameController extends EventDispatcher{
                 this.fence.Damage(damage);
                 let cameraUtils:CameraUtils=this.camera.getComponent(CameraUtils);
                 if(cameraUtils!=null){
-                    // cameraUtils.shake(100,)
+                    cameraUtils.shake(500,new Vec3(-0.01,-0.01,0),new Vec3(0.01,0.01,0));
                 }
             }
         }else{

Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác