This commit is contained in:
2025-07-25 13:23:54 +08:00
parent ac12d8cfe6
commit 509121a2ab
13 changed files with 1586 additions and 478 deletions

View File

@@ -10,30 +10,35 @@ export default class HeroAnmComp extends Component{
private spine?: sp.Skeleton;
private _hasStop = true;
private default_anim:string='Idle'
onLoad () {
var spine = this.spine = this.getComponent('sp.Skeleton') as sp.Skeleton;
this._setMix('Walking', 'Idle');
this._setMix('Walking', 'Attacking');
this._setMix('Walking', 'Taunt');
this._setMix('Walking', 'Hurt');
this._setMix('Idle', 'Attacking');
this._setMix('Idle', 'Taunt');
this._setMix('Idle', 'Walking');
this._setMix('Idle', 'Hurt');
this._setMix('Attacking', 'Idle');
this._setMix('Attacking', 'Walking');
this._setMix('Attacking', 'Hurt');
this._setMix('Attacking', 'Taunt');
this._setMix('Taunt', 'Walking');
this._setMix('Taunt', 'Idle');
this._setMix('Taunt', 'Attacking');
this._setMix('Taunt', 'Hurt');
this._setMix('Hurt', 'Idle');
this._setMix('Hurt', 'Attacking');
this._setMix('Hurt', 'Taunt');
this._setMix('Hurt', 'Walking');
spine.setCompleteListener((trackEntry) => {
var animationName = trackEntry.animation ? trackEntry.animation.name : "";
if (animationName === 'Attacking'||animationName==='Taunt'||animationName==='Hurt') {
this.spine!.clearTrack(1);
if(this.node.parent.getComponent(HeroViewComp).fac==FacSet.HERO){
this.spine?.setAnimation(0, 'Idle', false);
}
this.spine?.setAnimation(0, this.default_anim, true);
}
var loopCount = Math.floor(trackEntry.trackTime / trackEntry.animationEnd);
// console.log("[track %s][animation %s] complete: %s", trackEntry.trackIndex, animationName, loopCount);
@@ -85,6 +90,7 @@ export default class HeroAnmComp extends Component{
this.spine?.setToSetupPose();
}
this.spine?.setAnimation(0, 'Walking', true);
this.default_anim='Walking'
this._hasStop = false;
}
atk () {
@@ -100,6 +106,7 @@ export default class HeroAnmComp extends Component{
idle () {
this.spine?.setToSetupPose();
this.spine?.setAnimation(0, 'Idle', true);
this.default_anim='Idle'
}
_setMix (anim1: string, anim2: string) {

View File

@@ -132,7 +132,7 @@ export class HeroViewComp extends CCComp {
const collider = this.node.getComponent(BoxCollider2D);
this.scheduleOnce(()=>{
if (collider) collider.enabled = true; // 先禁用
},2)
},1)
// let anm = this.node.getChildByName("anm")
// anm.setScale(anm.scale.x*0.8,anm.scale.y*0.8);
}

View File

@@ -35,10 +35,12 @@ export class Monster extends ecs.Entity {
let box_group=BoxSet.MONSTER
console.log("mon load",uuid)
// this.addComponents<ecs.Comp>( MonModelComp, BattleMoveComp);
var scene = smc.map.MapView.scene;
this.brith_light(pos,scene)
var path = "game/heros/"+HeroInfo[uuid].path;
var prefab: Prefab = oops.res.get(path, Prefab)!;
var node = instantiate(prefab);
var scene = smc.map.MapView.scene;
node.parent = scene.entityLayer!.node!
const collider = node.getComponent(BoxCollider2D);
if (collider) collider.enabled = false; // 先禁用 // 延迟一帧启用碰撞体
@@ -51,7 +53,13 @@ export class Monster extends ecs.Entity {
move.direction = -1; // 向左移动
move.targetX = -800; // 左边界
}
brith_light(pos:Vec3,scene:any){
var path = "game/skills/map_birth";
var prefab: Prefab = oops.res.get(path, Prefab)!;
var node = instantiate(prefab);
node.parent = scene.entityLayer!.node!
node.setPosition(pos)
}
hero_init(uuid:number=1001,node:Node,scale:number=1,box_group=BoxSet.HERO,is_boss:boolean=false,is_call:boolean=false,lv:number=1,rogueBuffData?: any[]) {
var hv = node.getComponent(HeroViewComp)!;
hv.hide_info()