Files
heros/assets/script/game/map/HeroReadyCom.ts

36 lines
1.1 KiB
TypeScript

import { _decorator, Animation, AnimationClip, CCInteger, Component, Node, resources } from 'cc';
import { smc } from '../common/SingletonModuleComp';
import { HeroInfo } from '../common/config/heroSet';
const { ccclass, property } = _decorator;
@ccclass('HeroReadyCom')
export class HeroReadyCom extends Component {
@property(CCInteger)
slot: number=0;
start() {
this.update_hero()
}
update(deltaTime: number) {
}
update_hero(){
let hero = smc.fight_heros[this.slot]
if(hero==0){
return
}
let hero_data = HeroInfo[hero]
console.log("[HeroReadyCom]hero_data",smc.fight_heros,hero,smc.fight_heros[this.slot],this.slot,hero_data)
let anm_path=hero_data.path
resources.load("game/heros/hero/"+anm_path+"/idle", AnimationClip, (err, clip) => {
this.node.getChildByName("icon").getComponent(Animation).addClip(clip);
this.node.getChildByName("icon").getComponent(Animation).play("idle");
});
// console.log("[HeroReadyCom]clip",this.node.getChildByName("icon").getComponent(Animation))
}
}