Browse Source

图标修复9.19

181404010226 2 months ago
parent
commit
c2fe86a50e

+ 9 - 0
assets/scripts/Ads.meta

@@ -0,0 +1,9 @@
+{
+  "ver": "1.2.0",
+  "importer": "directory",
+  "imported": true,
+  "uuid": "76adde75-40f6-4489-bab2-5dd1c4818ad0",
+  "files": [],
+  "subMetas": {},
+  "userData": {}
+}

+ 15 - 8
assets/scripts/Animations/BallAni.ts

@@ -1,5 +1,6 @@
 import { _decorator, Component, Node, Vec3, tween, Color,find, Sprite, resources, sp, Material } from 'cc';
 import EventBus, { GameEvents } from '../Core/EventBus';
+import { BundleLoader } from '../Core/BundleLoader';
 const { ccclass, property } = _decorator;
 
 /**
@@ -251,15 +252,18 @@ export class BallAni extends Component {
         }
         
         BallAni.isLoading = true;
-        const path = 'Animation/WeaponTx/tx0005/tx0005';
-        resources.load(path, sp.SkeletonData, (err, sData: sp.SkeletonData) => {
+        const path = 'WeaponTx/tx0005/tx0005';
+        BundleLoader.loadSkeletonData(path).then((sData) => {
             BallAni.isLoading = false;
-            if (err || !sData) {
-                console.warn('[BallAni] 加载撞击特效失败:', err);
+            if (!sData) {
+                console.warn('[BallAni] 加载撞击特效失败: 资源为空');
                 return;
             }
             BallAni.impactEffectSkeleton = sData;
             console.log('[BallAni] 撞击特效资源加载成功');
+        }).catch((err) => {
+            BallAni.isLoading = false;
+            console.warn('[BallAni] 加载撞击特效失败:', err);
         });
     }
     
@@ -302,14 +306,17 @@ export class BallAni extends Component {
         }
         
         // 最后才使用动态加载
-        const path = 'Animation/WeaponTx/tx0005/tx0005';
-        resources.load(path, sp.SkeletonData, (err, sData: sp.SkeletonData) => {
-            if (err || !sData) {
-                console.warn('[BallAni] 加载撞击特效失败:', err);
+        const path = 'WeaponTx/tx0005/tx0005';
+        const bundleLoader = BundleLoader.getInstance();
+        BundleLoader.loadSkeletonData(path).then((sData) => {
+            if (!sData) {
+                console.warn('[BallAni] 加载撞击特效失败: 资源为空');
                 return;
             }
             BallAni.impactEffectSkeleton = sData;
             this.createAndPlayEffect(worldPosition, sData);
+        }).catch((err) => {
+            console.warn('[BallAni] 加载撞击特效失败:', err);
         });
     }
     

+ 9 - 4
assets/scripts/CombatSystem/BlockManager.ts

@@ -2479,10 +2479,13 @@ export class BlockManager extends Component {
 
     /** 生成烟雾特效 */
     private spawnMergeSmoke(worldPos: Vec3) {
-        const path = 'Animation/WeaponTx/tx0003/tx0003';
-        resources.load(path, sp.SkeletonData, (err, sData: sp.SkeletonData) => {
-            if (err || !sData) {
-                console.warn('加载合成烟雾动画失败', err);
+        // 使用BundleLoader加载Animation Bundle中的特效资源
+        // 转换路径格式,去除"Animation/"前缀
+        const bundlePath = 'WeaponTx/tx0003/tx0003';
+        
+        BundleLoader.loadSkeletonData(bundlePath).then((sData: sp.SkeletonData) => {
+            if (!sData) {
+                console.warn('加载合成烟雾动画失败: 资源为空');
                 return;
             }
             const node = new Node('MergeSmoke');
@@ -2495,6 +2498,8 @@ export class BlockManager extends Component {
             const canvas = find('Canvas');
             if (canvas) canvas.addChild(node);
             node.setWorldPosition(worldPos);
+        }).catch((err) => {
+            console.warn('加载合成烟雾动画失败:', err);
         });
     }
 

+ 22 - 12
assets/scripts/CombatSystem/BulletEffects/BulletHitEffect.ts

@@ -1,4 +1,4 @@
-import { _decorator, Component, Node, Vec3, find, instantiate, Prefab, UITransform, resources, sp, CircleCollider2D, Contact2DType, Collider2D, IPhysics2DContact } from 'cc';
+import { _decorator, Component, Node, Vec3, find, instantiate, Prefab, UITransform, resources, sp, CircleCollider2D, Contact2DType, Collider2D, IPhysics2DContact, Animation } from 'cc';
 import { BulletTrajectory } from './BulletTrajectory';
 import { HitEffectConfig } from '../../Core/ConfigManager';
 import { PersistentSkillManager } from '../../FourUI/SkillSystem/PersistentSkillManager';
@@ -8,6 +8,7 @@ import { GroundBurnAreaManager } from './GroundBurnAreaManager';
 import { WeaponBullet } from '../WeaponBullet';
 import EventBus, { GameEvents } from '../../Core/EventBus';
 import { Audio } from '../../AudioManager/AudioManager';
+import { BundleLoader } from '../../Core/BundleLoader';
 const { ccclass, property } = _decorator;
 
 /**
@@ -699,12 +700,25 @@ export class BulletHitEffect extends Component {
     private spawnEffect(path: string, worldPos: Vec3, loop = false, parent?: Node, onCreated?: (effectNode: Node) => void): void {
         if (!path) return;
 
-        const spawnWithData = (skData: sp.SkeletonData) => {
+        // 使用BundleLoader加载Animation Bundle中的特效资源
+        // 转换路径格式,去除"Animation/"前缀
+        const bundlePath = path.replace(/^Animation\//, '');
+        const bundleLoader = BundleLoader.getInstance();
+        
+        // 使用loadSkeletonData加载骨骼动画资源,就像敌人动画那样
+        BundleLoader.loadSkeletonData(bundlePath).then((skData) => {
+            if (!skData) {
+                console.warn('加载特效失败: 资源为空', path);
+                return;
+            }
+            
+            // 创建特效节点
             const effectNode = new Node('Effect');
             const skeletonComp: sp.Skeleton = effectNode.addComponent(sp.Skeleton);
             skeletonComp.skeletonData = skData;
             skeletonComp.setAnimation(0, 'animation', loop);
 
+            // 设置父节点和位置
             const targetParent = parent || find('Canvas/GameLevelUI/enemyContainer') || find('Canvas');
             if (targetParent) {
                 targetParent.addChild(effectNode);
@@ -719,9 +733,12 @@ export class BulletHitEffect extends Component {
                 }
             }
 
+            // 非循环动画播放完毕后销毁节点
             if (!loop) {
                 skeletonComp.setCompleteListener(() => {
-                    effectNode.destroy();
+                    if (effectNode && effectNode.isValid) {
+                        effectNode.destroy();
+                    }
                 });
             }
             
@@ -729,15 +746,8 @@ export class BulletHitEffect extends Component {
             if (onCreated) {
                 onCreated(effectNode);
             }
-        };
-
-        // 先尝试直接加载给定路径
-        resources.load(path, sp.SkeletonData, (err, skData: sp.SkeletonData) => {
-            if (err) {
-                console.warn('加载特效失败:', path, err);
-                return;
-            }
-            spawnWithData(skData);
+        }).catch((err) => {
+            console.warn('加载特效失败:', path, err);
         });
     }
     

+ 9 - 3
assets/scripts/CombatSystem/EnemyController.ts

@@ -10,6 +10,7 @@ import EventBus, { GameEvents } from '../Core/EventBus';
 import { Wall } from './Wall';
 import { BurnEffect } from './BulletEffects/BurnEffect';
 import { Audio } from '../AudioManager/AudioManager';
+import { BundleLoader } from '../Core/BundleLoader';
 const { ccclass, property } = _decorator;
 
 
@@ -1102,11 +1103,16 @@ export class EnemyController extends BaseSingleton {
             }
         }
         
+        // 移除Animation/前缀,因为BundleLoader会从Bundle中加载
+        if (spinePath.startsWith('Animation/')) {
+            spinePath = spinePath.replace('Animation/', '');
+        }
+        
         console.log(`[EnemyController] 最终加载路径: ${spinePath}`);
 
-        resources.load(spinePath, sp.SkeletonData, (err, skeletonData) => {
-            if (err) {
-                console.warn(`加载敌人Spine动画失败: ${spinePath}`, err);
+        BundleLoader.loadSkeletonData(spinePath).then((skeletonData) => {
+            if (!skeletonData) {
+                console.warn(`加载敌人Spine动画失败: ${spinePath}`);
                 return;
             }
 

+ 2 - 1
assets/scripts/CombatSystem/EnemyInstance.ts

@@ -108,7 +108,8 @@ export class EnemyInstance extends Component {
                 throw new Error('敌人配置文件内容为空');
             }
             
-            EnemyInstance.enemyDatabase = enemyData;
+            // JsonAsset对象,需要访问.json属性获取实际数据
+            EnemyInstance.enemyDatabase = enemyData.json;
         } catch (error) {
             console.error('[EnemyInstance] 加载敌人配置失败:', error);
             throw error;

+ 17 - 10
assets/scripts/CombatSystem/SkillSelection/SkillButtonController.ts

@@ -1,7 +1,8 @@
-import { _decorator, Component, Node, Button, Label, Sprite, resources, SpriteFrame } from 'cc';
-import { SkillManager, SkillData } from './SkillManager';
+import { _decorator, Component, Node, Button, Sprite, Label, resources, SpriteFrame } from 'cc';
+import { SkillData, SkillManager } from './SkillManager';
 import { SkillButtonAnimator } from './SkillButtonAnimator';
 import { Audio } from '../../AudioManager/AudioManager';
+import { BundleLoader } from '../../Core/BundleLoader';
 
 const { ccclass, property } = _decorator;
 
@@ -108,20 +109,26 @@ export class SkillButtonController extends Component {
     /**
      * 更新技能图标
      */
-    private updateSkillIcon() {
+    private async updateSkillIcon() {
         if (!this.skillSpriteNode || !this._skillData) return;
 
         const sprite = this.skillSpriteNode.getComponent(Sprite);
         if (sprite) {
-            const framePath = `${this._skillData.iconPath}/spriteFrame`;
-            resources.load(framePath, SpriteFrame, (err, spriteFrame) => {
-                if (!err && spriteFrame && sprite && sprite.isValid) {
+            // 转换路径格式,去除"images/"前缀
+            const bundlePath = this._skillData.iconPath.replace(/^images\//, '');
+            
+            try {
+                // 使用BundleLoader从images Bundle加载SpriteFrame,需要添加/spriteFrame后缀
+                const bundleLoader = BundleLoader.getInstance();
+                const spriteFrame = await bundleLoader.loadSpriteFrame(bundlePath + '/spriteFrame');
+                
+                if (spriteFrame && sprite && sprite.isValid) {
                     sprite.spriteFrame = spriteFrame;
-                    console.log(`技能图标加载成功: ${this._skillData!.iconPath}`);
-                } else if (err) {
-                    console.warn(`加载技能图标失败: ${this._skillData!.iconPath}`, err);
+                    console.log(`技能图标加载成功: ${this._skillData.iconPath}`);
                 }
-            });
+            } catch (err) {
+                console.warn(`加载技能图标失败: ${this._skillData.iconPath}`, err);
+            }
         }
     }
 

+ 11 - 11
assets/scripts/CombatSystem/WeaponBullet.ts

@@ -81,7 +81,7 @@ export class WeaponBullet extends Component {
                 throw new Error('武器配置文件内容为空');
             }
             
-            WeaponBullet.weaponsData = weaponData;
+            WeaponBullet.weaponsData = weaponData.json;
         } catch (error) {
             console.error('[WeaponBullet] 武器配置文件加载失败:', error);
             throw error;
@@ -630,13 +630,13 @@ export class WeaponBullet extends Component {
             return;
         }
 
-        const framePath = `${bulletImagePath}/spriteFrame`;
-        resources.load(framePath, SpriteFrame, (err, spriteFrame) => {
-            if (err) {
-                console.error(`加载子弹SpriteFrame失败: ${err}`);
-                return;
-            }
-
+        // 转换路径格式,去除"images/"前缀
+        const bundlePath = bulletImagePath.replace(/^images\//, '');
+        const framePath = `${bundlePath}/spriteFrame`;
+        
+        // 使用BundleLoader从images Bundle加载SpriteFrame
+        const bundleLoader = BundleLoader.getInstance();
+        bundleLoader.loadSpriteFrame(framePath).then((spriteFrame) => {
             console.log("设置子弹外观");
             // Add comprehensive null safety checks before setting spriteFrame
             if (sprite && sprite.isValid && 
@@ -646,10 +646,10 @@ export class WeaponBullet extends Component {
                 console.log("设置子弹SpriteFrame成功");
                 // === 子弹大小控制:保持prefab预设的大小 ===
                 sprite.node.setScale(sprite.node.scale.x * 0.45, sprite.node.scale.y * 0.45, sprite.node.scale.z);
-                
             }
-        }
-    );
+        }).catch((err) => {
+            console.error(`加载子弹SpriteFrame失败: ${err}`);
+        });
     }
     
     /**

+ 15 - 4
assets/scripts/Core/BundleLoader.ts

@@ -1,4 +1,5 @@
-import { assetManager, JsonAsset, Asset, SpriteFrame } from 'cc';
+import { assetManager, JsonAsset, Asset, SpriteFrame, AnimationClip } from 'cc';
+import { sp } from 'cc';
 
 /**
  * Bundle资源加载器
@@ -127,10 +128,20 @@ export class BundleLoader {
     /**
      * 从Animation Bundle加载动画资源的便捷方法
      * @param resourcePath 资源路径(相对于Animation Bundle根目录)
-     * @returns Promise<Asset>
+     * @returns Promise<AnimationClip>
+     */
+    public async loadAnimation(resourcePath: string): Promise<AnimationClip> {
+        return this.loadAssetFromBundle<AnimationClip>('Animation', resourcePath, AnimationClip);
+    }
+
+    /**
+     * 从Animation Bundle加载骨骼动画数据
+     * @param resourcePath 资源路径(相对于Bundle根目录)
+     * @returns Promise<sp.SkeletonData>
      */
-    public async loadAnimation(resourcePath: string): Promise<Asset> {
-        return this.loadAssetFromBundle('Animation', resourcePath);
+    public static async loadSkeletonData(resourcePath: string): Promise<sp.SkeletonData> {
+        const instance = BundleLoader.getInstance();
+        return instance.loadAssetFromBundle('Animation', resourcePath, sp.SkeletonData);
     }
 
     /**

+ 2 - 2
assets/scripts/FourUI/UpgradeSystem/UpgradeAni.ts

@@ -261,8 +261,8 @@ export class UpgradeAni extends Component {
                 throw new Error('武器配置文件内容为空');
             }
             
-            this.weaponsConfig = weaponData;
-            console.log('[UpgradeAni] 武器配置加载成功');
+            this.weaponsConfig = weaponData.json;
+            console.log('[UpgradeAni] 武器配置加载成功:', this.weaponsConfig);
         } catch (error) {
             console.error('[UpgradeAni] 加载武器配置失败:', error);
             throw error;

+ 20 - 0
assets/scripts/LaunchScreen.ts

@@ -1,6 +1,26 @@
 import { _decorator, Component, Node, director, assetManager, ProgressBar, Label, Sprite, SpriteFrame, resources } from 'cc';
 const { ccclass, property } = _decorator;
 
+// 微信小游戏API类型声明
+declare global {
+    interface Window {
+        wx?: {
+            loadSubpackage?: (options: {
+                name: string;
+                success?: () => void;
+                fail?: (err: any) => void;
+            }) => any;
+        };
+    }
+    const wx: {
+        loadSubpackage?: (options: {
+            name: string;
+            success?: () => void;
+            fail?: (err: any) => void;
+        }) => any;
+    } | undefined;
+}
+
 @ccclass('LaunchScreen')
 export class LaunchScreen extends Component {
     @property(ProgressBar)