角色动画 确定

This commit is contained in:
walkpan
2024-08-26 07:33:26 +08:00
parent 68d7077e56
commit 4f96558d36
111 changed files with 54661 additions and 1391 deletions

View File

@@ -0,0 +1,74 @@
/*
* @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 ,Node} from "cc";
import { LayerUtil } from "../../../../../extensions/oops-plugin-framework/assets/core/utils/LayerUtil";
import { smc } from "../../common/SingletonModuleComp";
import Role2SpineAnimator from "./Role2SpineAnimator";
const { ccclass, property } = _decorator;
/**
* SPINE角色模型
*/
@ccclass('Role2Spine')
export class Role2Spine extends Component {
@property({ type: Role2SpineAnimator, tooltip: '动画控制器' })
animator: Role2SpineAnimator = null!;
private spine!: sp.Skeleton;
onLoad() {
// 角色控制组件
this.initAnimator();
LayerUtil.setNodeLayer(LayerUtil.MAP, this.node);
}
atk() {
this.spine.setAnimation(1, "atk", false);
}
magic() {
this.spine.setAnimation(1, "magic", false);
}
/** 初始化动画 */
protected initAnimator() {
this.spine = this.animator.getComponent(sp.Skeleton)!;
}
setSkin(value: string): void {
console.log("RoleSpine setSkin", value);
this.spine.setSkin(value);
}
play(animName: string, loop: boolean): void {
this.spine.setAnimation(1, animName, loop);
}
setAlpha(value: number): void {
var color: Color = this.spine.color;
color.a = 255 * (value / 1);
this.spine.color = color;
}
setPos(value: Vec3): void {
this.node.position = value;
}
checkTouch(event: EventTouch): boolean {
return false;
}
onDestroy() {
this.node.destroy();
}
walk() {
}
idle() {
}
}