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

This commit is contained in:
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, Animation, Label, resources, SpriteAtlas,Sprite } from "cc";
import { _decorator, Animation, Label, resources, SpriteAtlas,Sprite, Skeleton, SkinnedMeshRenderer, 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";
@@ -150,22 +150,47 @@ export class CardComp extends CCComp {
});
show.getChildByName("info").getComponent(Label).string=SkillSet[uuid].info
}
/* 英雄 直接加载骨骼动画 */ //注意 动画名称为Idle
show_hero(uuid:number){
let show=this.node.getChildByName("show")
show.getChildByName("name").getChildByName("name").getComponent(Label).string=HeroInfo[uuid].name
this.do_card_bg_show(HeroInfo[uuid].quality)
this.node.getChildByName("show").getChildByName("coins").active=false
// show.getChildByName("ap").active=true
// show.getChildByName("hp").active=true
// show.getChildByName("ap").getChildByName("num").getComponent(Label).string=HeroInfo[uuid].ap.toString()
// show.getChildByName("hp").getChildByName("num").getComponent(Label).string=HeroInfo[uuid].hp.toString()
// show.getChildByName("lv").getChildByName("num").getComponent(Label).string=HeroInfo[uuid].lv.toString()
var icon_path = "game/heros/herois"
resources.load(icon_path, SpriteAtlas, (err: any, atlas) => {
const sprite = show.getChildByName("mask").getChildByName("hero").getComponent(Sprite);
sprite.spriteFrame = atlas.getSpriteFrame(HeroInfo[uuid].path);
show.getChildByName("coins").active=false
var icon_path = "game/heros/heros/"+HeroInfo[uuid].path
resources.load(icon_path, sp.SkeletonData, (err, skeleton) => {
if (err) {
console.error("[CardComp]: 加载骨骼数据失败:", err);
return;
}
console.log("[CardComp]: 加载骨骼数据成功:", skeleton)
// 检查节点是否仍然存在
const maskNode = show.getChildByName("mask");
if (!maskNode) {
console.error("[CardComp]: mask节点不存在");
return;
}
const heroNode = maskNode.getChildByName("hero");
if (!heroNode) {
console.error("[CardComp]: hero节点不存在");
return;
}
const spine = heroNode.getComponent(sp.Skeleton);
if (!spine) {
console.error("[CardComp]: hero节点上没有找到SkinnedMeshRenderer组件");
return;
}
if (spine) {
spine.skeletonData = skeleton;
spine.setAnimation(0, "Idle", true);
}
});
// resources.load(icon_path, SpriteAtlas, (err: any, atlas) => {
// const sprite = show.getChildByName("mask").getChildByName("hero").getComponent(Sprite);
// sprite.spriteFrame = atlas.getSpriteFrame(HeroInfo[uuid].path);
// });
show.getChildByName("info").getComponent(Label).string=HeroInfo[uuid].info
}

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
}
/**