英雄icon 直接使用json动画,不需要icon图片了

This commit is contained in:
panfudan
2025-08-07 00:34:59 +08:00
parent d77ce672b3
commit 471248eba8
94 changed files with 17523 additions and 27211 deletions

View File

@@ -1,4 +1,4 @@
import { _decorator, resources, Sprite, SpriteAtlas ,Node, ProgressBar, tween, v3, Label, Animation, CCString, CCInteger} from "cc";
import { _decorator, resources, Sprite, SpriteAtlas ,Node, ProgressBar, tween, v3, Label, Animation, CCString, CCInteger, sp} from "cc";
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
import { GameEvent } from "../common/config/GameEvent";
@@ -174,17 +174,16 @@ export class HeroUiComp extends CCComp {
* @param heroPath 英雄路径
*/
private loadHeroIcon(iconNode: Node, heroPath: string) {
const iconPath = "game/heros/herois"
resources.load(iconPath, SpriteAtlas, (err: any, atlas) => {
if (err) {
console.error("[HeroUiComp]: Failed to load hero icon atlas:", err)
return
iconNode.parent.getChildByName("iconbg").active=false
const icon_path = "game/heros/heros/"+heroPath
resources.load(icon_path, sp.SkeletonData, (err, skeleton) => {
const spine = iconNode.getComponent(sp.Skeleton);
if (spine) {
spine.skeletonData = skeleton;
spine.setAnimation(0, "Idle", true);
}
const sprite = iconNode.getComponent(Sprite)
if (sprite && atlas) {
sprite.spriteFrame = atlas.getSpriteFrame(heroPath)
}
})
});
}
/**
@@ -219,6 +218,8 @@ export class HeroUiComp extends CCComp {
if (iconNode) {
iconNode.active = false
}
heroNode.getChildByName("iconbg").active=true
}
/**