woso_javan hace 1 mes
padre
commit
086de4f8e1

+ 5 - 3
assets/module_aliens/Script/Components/ScreenShotComponent.ts

@@ -2,6 +2,7 @@ import { _decorator, Camera, Component, Node, RenderTexture, Sprite, SpriteFrame
 import { AliensGlobalInstance } from '../AliensGlobalInstance';
 import { EventDispatcher } from 'db://assets/core_tgx/easy_ui_framework/EventDispatcher';
 import { GameEvent } from '../Enum/GameEvent';
+import { GameUtil } from '../GameUtil';
 const { ccclass, property } = _decorator;
 /** 截图组件脚本*/
 @ccclass('ScreenShotComponent')
@@ -19,8 +20,8 @@ export class ScreenShotComponent extends Component {
     async start() {
         this.registerEvent();
         //获取相机组件 
-        const camera = await this.getSceneCamera();
-        this._originalTargetTexture = camera.targetTexture;
+        // const camera = await this.getSceneCamera();
+        // this._originalTargetTexture = camera.targetTexture;
     }
 
     private registerEvent(){
@@ -84,7 +85,7 @@ export class ScreenShotComponent extends Component {
                 camera.node.setRotationFromEuler(this._originalCameraRotation);
                 // 强制更新材质
                 this.sprite.markForUpdateRenderData();
-            }, 0.1);  // 稍微延长等待时间确保渲染完成
+            }, 0.1);
         }
     }
 
@@ -112,6 +113,7 @@ export class ScreenShotComponent extends Component {
     public saveCameraState(pos:Vec3,rotation:Vec3){
         this._originalCameraPosition = pos;
         this._originalCameraRotation = rotation;
+        console.log('保存相机最新的位置和旋转角度:',pos,',',rotation);
     }
 
     protected onDestroy(): void {

+ 5 - 3
assets/module_aliens/Script/LevelAction.ts

@@ -5,6 +5,7 @@ import { LineDrawer } from './LineDrawer';
 import { EnemyComponent } from './Components/EnemyComponent';
 import { AliensGlobalInstance } from './AliensGlobalInstance';
 import { ScreenShotComponent } from './Components/ScreenShotComponent';
+import { GameUtil } from './GameUtil';
 
 const { ccclass, property } = _decorator;
 
@@ -49,6 +50,7 @@ export class LevelAction extends Component {
 
     start() {
         this.initilizeUI();
+        this.saveCameraState();
     }
 
     private initilizeUI(){
@@ -168,7 +170,7 @@ export class LevelAction extends Component {
         this._originalRotation = this.camera.node.eulerAngles.clone();
     }
     
-    private _onTouchMove(event: EventTouch) {
+    private async _onTouchMove(event: EventTouch) {
         if (!this._isDragging) return;
         
         const currentPos = event.getLocation();
@@ -185,11 +187,11 @@ export class LevelAction extends Component {
         newRotation.y = Math.max(this.minYRotation, Math.min(this.maxYRotation, newRotation.y));
         
         this.camera.node.setRotationFromEuler(newRotation);
-        this.saveCameraState();
+        await this.saveCameraState();
     }
 
     //保存相机的位置和旋转角度
-    private saveCameraState() {
+    private async saveCameraState() {
         const cameraOriginalPos = this.camera.node.worldPosition.clone();
         const originalRotation = this.camera.node.eulerAngles.clone(); 
         const screenShot = AliensGlobalInstance.instance.renderNode.getComponent(ScreenShotComponent)!;

+ 16 - 16
profiles/v2/packages/scene.json

@@ -1214,8 +1214,8 @@
     },
     "19323c5d-5d36-438a-86ee-8288c690e5b0": {
       "position": {
-        "x": 63.841666666666654,
-        "y": 135.9083333333333,
+        "x": 112.43749999999994,
+        "y": 101.20833333333329,
         "z": 5000
       },
       "rotation": {
@@ -1230,17 +1230,17 @@
         "z": 0
       },
       "contentRect": {
-        "x": 164,
+        "x": 386.5,
         "y": 346,
-        "width": 318,
-        "height": 670.9024390243902
+        "width": 761.8294797687861,
+        "height": 682
       },
-      "scale": 0.9695121951219512
+      "scale": 0.9855491329479769
     },
     "9e293cde-e27b-4902-808b-e884f3e9da32": {
       "position": {
-        "x": 164.00000000000003,
-        "y": 346,
+        "x": 180,
+        "y": 380.00000000000006,
         "z": 5000
       },
       "rotation": {
@@ -1257,15 +1257,15 @@
       "contentRect": {
         "x": 0,
         "y": 0,
-        "width": 318,
-        "height": 670.9024390243902
+        "width": 350,
+        "height": 738.8888888888889
       },
-      "scale": 0.9695121951219512
+      "scale": 0.9722222222222222
     },
     "be14c61f-22d8-4bb9-b444-ad9f29740469": {
       "position": {
-        "x": 386.5,
-        "y": 364,
+        "x": 389.9868164605463,
+        "y": 679.657014651601,
         "z": 5000
       },
       "rotation": {
@@ -1280,12 +1280,12 @@
         "z": 0
       },
       "contentRect": {
-        "x": 225.28551532033427,
-        "y": 23.876757931924736,
+        "x": 50.15768564996603,
+        "y": -37.76003928184644,
         "width": 762.3818681318681,
         "height": 718
       },
-      "scale": 0.9862637362637363
+      "scale": 0.5149646811695624
     }
   },
   "camera-uuids": [