Files
heros/assets/script/game/Role/RoleSpine.ts

58 lines
1.8 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* @Author: dgflash
* @Date: 2022-08-04 15:08:35
* @LastEditors: dgflash
* @LastEditTime: 2022-08-04 15:26:26
*/
import { Color, Component, EventTouch, sp, Vec3, _decorator ,Animation, AnimationClip, AnimationState} from "cc";
import { LayerUtil } from "../../../../extensions/oops-plugin-framework/assets/core/utils/LayerUtil";
import { smc } from "../common/SingletonModuleComp";
import RoleSpineAnimator from "./RoleSpineAnimator";
const { ccclass, property } = _decorator;
/**
* SPINE角色模型
*/
@ccclass('RoleSpine')
export class RoleSpine extends Component {
private loop: boolean = true;
private spine!: sp.Skeleton;
private default:string = "idle";
private atk_name: string = "atk";
private move_name: string = "move";
private max_name: string = "max";
private idel_name: string = "idle";
start() {
this.spine.setAnimation(0, this.default, true);
}
mixTime:number= 0.2;
onLoad() {
this.spine = this.node.getChildByName("anm")!.getComponent(sp.Skeleton);
this.spine.setEndListener(trackEntry => {
var animationName = trackEntry.animation ? trackEntry.animation.name : "";
// console.log("[track %s][animation %s] end.", trackEntry.trackIndex, animationName);
if (animationName == "atk" || animationName== "max" ) {
this.spine.setAnimation(0, this.default, true);
}
});
}
protected play(animName: string, loop: boolean) {
}
atk(){
this.spine.setAnimation(0, this.atk_name, false);
}
idle(){
this.spine.setAnimation(0, this.idel_name, true);
}
move(){
this.spine.setAnimation(0, this.move_name, true);
}
max(){
this.spine.setAnimation(0, this.max_name, false);
}
}