فهرست منبع

游戏开始动画完成

181404010226 4 ماه پیش
والد
کامیت
d239d045a2
2فایلهای تغییر یافته به همراه322 افزوده شده و 50 حذف شده
  1. 193 45
      assets/Scenes/GameLevel.scene
  2. 129 5
      assets/scripts/Animations/GameStartMove.ts

+ 193 - 45
assets/Scenes/GameLevel.scene

@@ -26,7 +26,7 @@
     "_active": true,
     "_components": [],
     "_prefab": {
-      "__id__": 938
+      "__id__": 942
     },
     "_lpos": {
       "__type__": "cc.Vec3",
@@ -57,7 +57,7 @@
     },
     "autoReleaseAssets": false,
     "_globals": {
-      "__id__": 939
+      "__id__": 943
     },
     "_id": "29694223-a59c-44b3-acb0-80ab92d103f5"
   },
@@ -79,6 +79,9 @@
       {
         "__id__": 917
       },
+      {
+        "__id__": 921
+      },
       {
         "__id__": 284
       },
@@ -113,25 +116,25 @@
         "__id__": 464
       },
       {
-        "__id__": 920
+        "__id__": 924
       },
       {
-        "__id__": 923
+        "__id__": 927
       }
     ],
     "_active": true,
     "_components": [
       {
-        "__id__": 934
+        "__id__": 938
       },
       {
-        "__id__": 935
+        "__id__": 939
       },
       {
-        "__id__": 936
+        "__id__": 940
       },
       {
-        "__id__": 937
+        "__id__": 941
       }
     ],
     "_prefab": null,
@@ -281,6 +284,9 @@
     "grayNode": {
       "__id__": 266
     },
+    "targetLineNode": {
+      "__id__": 917
+    },
     "_id": "94zhw8gFlC+Z8zKBZ4H21f"
   },
   {
@@ -308,7 +314,7 @@
     "_lpos": {
       "__type__": "cc.Vec3",
       "x": 0,
-      "y": -864.5,
+      "y": -820,
       "z": 0
     },
     "_lrot": {
@@ -410,7 +416,7 @@
     "_left": -140,
     "_right": -140,
     "_top": 0,
-    "_bottom": -200,
+    "_bottom": -155.5,
     "_horizontalCenter": 0,
     "_verticalCenter": 0,
     "_isAbsLeft": true,
@@ -34500,7 +34506,7 @@
   },
   {
     "__type__": "cc.Node",
-    "_name": "ConfigManager",
+    "_name": "Line4",
     "_objFlags": 0,
     "__editorExtras__": {},
     "_parent": {
@@ -34514,6 +34520,148 @@
       },
       {
         "__id__": 919
+      },
+      {
+        "__id__": 920
+      }
+    ],
+    "_prefab": null,
+    "_lpos": {
+      "__type__": "cc.Vec3",
+      "x": 0,
+      "y": -667.155,
+      "z": 0
+    },
+    "_lrot": {
+      "__type__": "cc.Quat",
+      "x": 0,
+      "y": 0,
+      "z": 0,
+      "w": 1
+    },
+    "_lscale": {
+      "__type__": "cc.Vec3",
+      "x": 1,
+      "y": 1,
+      "z": 1
+    },
+    "_mobility": 0,
+    "_layer": 1073741824,
+    "_euler": {
+      "__type__": "cc.Vec3",
+      "x": 0,
+      "y": 0,
+      "z": 0
+    },
+    "_id": "653cjMrYFF+KAgX/0yfo6p"
+  },
+  {
+    "__type__": "cc.UITransform",
+    "_name": "",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "node": {
+      "__id__": 917
+    },
+    "_enabled": true,
+    "__prefab": null,
+    "_contentSize": {
+      "__type__": "cc.Size",
+      "width": 1000,
+      "height": 5
+    },
+    "_anchorPoint": {
+      "__type__": "cc.Vec2",
+      "x": 0.5,
+      "y": 0.5
+    },
+    "_id": "1a3NHAGwRJYIhiZ8u3Kf+/"
+  },
+  {
+    "__type__": "cc.Sprite",
+    "_name": "",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "node": {
+      "__id__": 917
+    },
+    "_enabled": true,
+    "__prefab": null,
+    "_customMaterial": null,
+    "_srcBlendFactor": 2,
+    "_dstBlendFactor": 4,
+    "_color": {
+      "__type__": "cc.Color",
+      "r": 255,
+      "g": 255,
+      "b": 255,
+      "a": 0
+    },
+    "_spriteFrame": {
+      "__uuid__": "7d8f9b89-4fd1-4c9f-a3ab-38ec7cded7ca@f9941",
+      "__expectedType__": "cc.SpriteFrame"
+    },
+    "_type": 0,
+    "_fillType": 0,
+    "_sizeMode": 0,
+    "_fillCenter": {
+      "__type__": "cc.Vec2",
+      "x": 0,
+      "y": 0
+    },
+    "_fillStart": 0,
+    "_fillRange": 0,
+    "_isTrimmedMode": true,
+    "_useGrayscale": false,
+    "_atlas": null,
+    "_id": "6bmKLbkz1O76b8o47qbngF"
+  },
+  {
+    "__type__": "cc.Widget",
+    "_name": "",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "node": {
+      "__id__": 917
+    },
+    "_enabled": true,
+    "__prefab": null,
+    "_alignFlags": 44,
+    "_target": null,
+    "_left": -140,
+    "_right": -140,
+    "_top": 0,
+    "_bottom": -2.6549999999999727,
+    "_horizontalCenter": 0,
+    "_verticalCenter": 0,
+    "_isAbsLeft": true,
+    "_isAbsRight": true,
+    "_isAbsTop": true,
+    "_isAbsBottom": true,
+    "_isAbsHorizontalCenter": true,
+    "_isAbsVerticalCenter": true,
+    "_originalWidth": 1000,
+    "_originalHeight": 0,
+    "_alignMode": 2,
+    "_lockFlags": 0,
+    "_id": "d3uRpg3mNFeomUAntuwTGW"
+  },
+  {
+    "__type__": "cc.Node",
+    "_name": "ConfigManager",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "_parent": {
+      "__id__": 2
+    },
+    "_children": [],
+    "_active": true,
+    "_components": [
+      {
+        "__id__": 922
+      },
+      {
+        "__id__": 923
       }
     ],
     "_prefab": null,
@@ -34552,7 +34700,7 @@
     "_objFlags": 0,
     "__editorExtras__": {},
     "node": {
-      "__id__": 917
+      "__id__": 921
     },
     "_enabled": true,
     "__prefab": null,
@@ -34574,7 +34722,7 @@
     "_objFlags": 0,
     "__editorExtras__": {},
     "node": {
-      "__id__": 917
+      "__id__": 921
     },
     "_enabled": true,
     "__prefab": null,
@@ -34592,10 +34740,10 @@
     "_active": true,
     "_components": [
       {
-        "__id__": 921
+        "__id__": 925
       },
       {
-        "__id__": 922
+        "__id__": 926
       }
     ],
     "_prefab": null,
@@ -34634,7 +34782,7 @@
     "_objFlags": 0,
     "__editorExtras__": {},
     "node": {
-      "__id__": 920
+      "__id__": 924
     },
     "_enabled": true,
     "__prefab": null,
@@ -34656,7 +34804,7 @@
     "_objFlags": 0,
     "__editorExtras__": {},
     "node": {
-      "__id__": 920
+      "__id__": 924
     },
     "_enabled": true,
     "__prefab": null,
@@ -34672,19 +34820,19 @@
     },
     "_children": [
       {
-        "__id__": 924
+        "__id__": 928
       },
       {
-        "__id__": 928
+        "__id__": 932
       }
     ],
     "_active": true,
     "_components": [
       {
-        "__id__": 932
+        "__id__": 936
       },
       {
-        "__id__": 933
+        "__id__": 937
       }
     ],
     "_prefab": null,
@@ -34723,19 +34871,19 @@
     "_objFlags": 0,
     "__editorExtras__": {},
     "_parent": {
-      "__id__": 923
+      "__id__": 927
     },
     "_children": [],
     "_active": true,
     "_components": [
       {
-        "__id__": 925
+        "__id__": 929
       },
       {
-        "__id__": 926
+        "__id__": 930
       },
       {
-        "__id__": 927
+        "__id__": 931
       }
     ],
     "_prefab": null,
@@ -34774,7 +34922,7 @@
     "_objFlags": 0,
     "__editorExtras__": {},
     "node": {
-      "__id__": 924
+      "__id__": 928
     },
     "_enabled": true,
     "__prefab": null,
@@ -34796,7 +34944,7 @@
     "_objFlags": 0,
     "__editorExtras__": {},
     "node": {
-      "__id__": 924
+      "__id__": 928
     },
     "_enabled": true,
     "__prefab": null,
@@ -34835,7 +34983,7 @@
     "_objFlags": 0,
     "__editorExtras__": {},
     "node": {
-      "__id__": 924
+      "__id__": 928
     },
     "_enabled": true,
     "__prefab": null,
@@ -34865,19 +35013,19 @@
     "_objFlags": 0,
     "__editorExtras__": {},
     "_parent": {
-      "__id__": 923
+      "__id__": 927
     },
     "_children": [],
     "_active": true,
     "_components": [
       {
-        "__id__": 929
+        "__id__": 933
       },
       {
-        "__id__": 930
+        "__id__": 934
       },
       {
-        "__id__": 931
+        "__id__": 935
       }
     ],
     "_prefab": null,
@@ -34916,7 +35064,7 @@
     "_objFlags": 0,
     "__editorExtras__": {},
     "node": {
-      "__id__": 928
+      "__id__": 932
     },
     "_enabled": true,
     "__prefab": null,
@@ -34938,7 +35086,7 @@
     "_objFlags": 0,
     "__editorExtras__": {},
     "node": {
-      "__id__": 928
+      "__id__": 932
     },
     "_enabled": true,
     "__prefab": null,
@@ -35000,7 +35148,7 @@
     "_objFlags": 0,
     "__editorExtras__": {},
     "node": {
-      "__id__": 928
+      "__id__": 932
     },
     "_enabled": true,
     "__prefab": null,
@@ -35030,7 +35178,7 @@
     "_objFlags": 0,
     "__editorExtras__": {},
     "node": {
-      "__id__": 923
+      "__id__": 927
     },
     "_enabled": true,
     "__prefab": null,
@@ -35052,7 +35200,7 @@
     "_objFlags": 0,
     "__editorExtras__": {},
     "node": {
-      "__id__": 923
+      "__id__": 927
     },
     "_enabled": true,
     "__prefab": null,
@@ -35150,28 +35298,28 @@
   {
     "__type__": "cc.SceneGlobals",
     "ambient": {
-      "__id__": 940
+      "__id__": 944
     },
     "shadows": {
-      "__id__": 941
+      "__id__": 945
     },
     "_skybox": {
-      "__id__": 942
+      "__id__": 946
     },
     "fog": {
-      "__id__": 943
+      "__id__": 947
     },
     "octree": {
-      "__id__": 944
+      "__id__": 948
     },
     "skin": {
-      "__id__": 945
+      "__id__": 949
     },
     "lightProbeInfo": {
-      "__id__": 946
+      "__id__": 950
     },
     "postSettings": {
-      "__id__": 947
+      "__id__": 951
     },
     "bakedWithStationaryMainLight": false,
     "bakedWithHighpLightmap": false

+ 129 - 5
assets/scripts/Animations/GameStartMove.ts

@@ -45,7 +45,12 @@ export class GameStartMove extends Component {
     @property({ type: Node, tooltip: 'Canvas/GameLevelUI/Gray节点' })
     public grayNode: Node = null;
 
-
+    /** 目标线节点,diban下滑结束后相机将移动到此线的位置 */
+    @property({ 
+        type: Node, 
+        tooltip: 'Target line node. Camera will move to show this line at the bottom after diban slide down animation.' 
+    })
+    public targetLineNode: Node = null;
 
     private _originalDibanPos: Vec3 = new Vec3();
 
@@ -108,6 +113,46 @@ export class GameStartMove extends Component {
             .start();
     }
 
+    /**
+     * Smoothly move the camera down to show the reference line at bottom.
+     * Requires referenceLineNode to be set.
+     * @param duration 动画时长,默认使用moveDuration
+     */
+    public moveDownSmooth(duration?: number) {
+        if (!this.cameraNode) return;
+        
+        const startPos = this.cameraNode.position.clone();
+        
+        // Calculate movement based on reference line position
+        const moveDistance = this.calculateMoveDistanceToShowLine();
+        if (moveDistance <= 0) return;
+        
+        const targetPos = new Vec3(startPos.x, startPos.y - moveDistance, startPos.z);
+        
+        console.log('GameStartMove.moveDownSmooth 镜头平滑下移,开始执行:', {
+            startPos: startPos,
+            targetPos: targetPos,
+            moveDistance: moveDistance
+        });
+        
+        // Stop any running tweens on this node to avoid conflicting animations.
+        Tween.stopAllByTarget(this.cameraNode);
+        
+        // 使用传入的duration或默认的moveDuration
+        const animationDuration = duration !== undefined ? duration : this.moveDuration;
+        
+        tween(this.cameraNode)
+            .to(animationDuration, { position: targetPos }, { easing: 'quadOut' })
+            .call(() => {
+                console.log('GameStartMove.moveDownSmooth 镜头平滑下移完成');
+                // 镜头下移完成时显示Gray遮罩
+                if (this.grayNode) {
+                    this.grayNode.active = true;
+                }
+            })
+            .start();
+    }
+
 
 
 
@@ -156,6 +201,85 @@ export class GameStartMove extends Component {
         return Math.max(0, moveDistance); // Ensure we don't move in wrong direction
     }
 
+    /**
+     * Calculate the distance camera needs to move to show the target line at the bottom of the view.
+     * @returns The movement distance in world units
+     */
+    private calculateMoveDistanceToShowTargetLine(): number {
+        if (!this.targetLineNode || !this.cameraNode) {
+            console.warn('GameStartMove.calculateMoveDistanceToShowTargetLine: targetLineNode or cameraNode not set');
+            return 0;
+        }
+
+        // Get the camera component
+        const cameraComponent = this.cameraNode.getComponent(Camera);
+        if (!cameraComponent) {
+            console.warn('GameStartMove.calculateMoveDistanceToShowTargetLine: Camera component not found');
+            return 0;
+        }
+
+        // Get the target line's world position
+        const targetLineWorldPos = this.targetLineNode.getWorldPosition();
+        
+        // Get camera's current world position
+        const cameraWorldPos = this.cameraNode.getWorldPosition();
+        
+        // Calculate camera's view height in world units
+        // For orthographic camera, orthoHeight represents half of the view height
+        const cameraViewHalfHeight = cameraComponent.orthoHeight;
+        
+        // Calculate the distance to move camera so that the target line appears at the bottom
+        // We want: cameraWorldPos.y - cameraViewHalfHeight = targetLineWorldPos.y
+        // So: moveDistance = cameraWorldPos.y - targetLineWorldPos.y - cameraViewHalfHeight
+        const moveDistance = cameraWorldPos.y - targetLineWorldPos.y - cameraViewHalfHeight;
+        
+        console.log('GameStartMove.calculateMoveDistanceToShowTargetLine 计算移动距离:', {
+            targetLineWorldPos: targetLineWorldPos,
+            cameraWorldPos: cameraWorldPos,
+            cameraViewHalfHeight: cameraViewHalfHeight,
+            moveDistance: moveDistance
+        });
+        
+        return moveDistance; // Allow both positive and negative movement
+    }
+
+    /**
+     * 平滑移动相机到目标线位置
+     * @param duration 动画时长,默认 0.3s
+     */
+    public moveCameraToTargetLineSmooth(duration: number = 0.3) {
+        if (!this.cameraNode || !this.targetLineNode) {
+            console.warn('GameStartMove.moveCameraToTargetLineSmooth: cameraNode or targetLineNode not set');
+            return;
+        }
+        
+        const moveDistance = this.calculateMoveDistanceToShowTargetLine();
+        if (moveDistance === 0) {
+            console.log('GameStartMove.moveCameraToTargetLineSmooth: 无需移动相机');
+            return;
+        }
+        
+        const startPos = this.cameraNode.position.clone();
+        const targetPos = new Vec3(startPos.x, startPos.y - moveDistance, startPos.z);
+        
+        console.log('GameStartMove.moveCameraToTargetLineSmooth 相机移动到目标线:', {
+            startPos: startPos,
+            targetPos: targetPos,
+            moveDistance: moveDistance
+        });
+        
+        // 停止任何正在运行的相机动画
+        Tween.stopAllByTarget(this.cameraNode);
+        
+        // 执行平滑移动动画
+        tween(this.cameraNode)
+            .to(duration, { position: targetPos }, { easing: 'quadOut' })
+            .call(() => {
+                console.log('GameStartMove.moveCameraToTargetLineSmooth 相机移动到目标线完成');
+            })
+            .start();
+    }
+
     /**
      * 获取参考线在diban父节点坐标系中的位置和diban高度
      * @returns 包含referenceLineLocalPos和dibanHeight的对象,如果节点未设置则返回null
@@ -218,8 +342,8 @@ export class GameStartMove extends Component {
             })
             .start();
             
-        // 同时执行camera下移动画
-        this.moveDownInstant();
+        // 同时执行camera平滑下移动画
+        this.moveDownSmooth(duration);
     }
 
     /**
@@ -273,8 +397,8 @@ export class GameStartMove extends Component {
             })
             .start();
             
-        // 同时执行camera上移动画
-        this.moveUpSmooth();
+        // 在diban下滑动画开始的同时,相机平滑移动到目标线位置
+        this.moveCameraToTargetLineSmooth(0.3);
         
         console.log('GameStartMove.slideDibanDownAndHide diban下滑动画已启动');
     }