This commit is contained in:
2024-07-21 22:39:39 +08:00
parent 883261dac6
commit 064b6bf1ae
14 changed files with 348 additions and 43 deletions

View File

@@ -7,6 +7,7 @@
import { Color, Component, EventTouch, sp, Vec3, _decorator } from "cc";
import { LayerUtil } from "../../../../../extensions/oops-plugin-framework/assets/core/utils/LayerUtil";
import { smc } from "../../common/SingletonModuleComp";
// import Charactor, { CharactorDirection, CharactorState } from "../../map/view/map/charactor/Charactor";
import RoleSpineAnimator from "./RoleSpineAnimator";
const { ccclass, property } = _decorator;
@@ -18,30 +19,47 @@ const { ccclass, property } = _decorator;
export class RoleSpine extends Component {
@property({ type: RoleSpineAnimator, tooltip: '动画控制器' })
animator: RoleSpineAnimator = null!;
private spine!: sp.Skeleton;
// private charactor!: Charactor;
onLoad() {
// 角色控制组件
// this.charactor = this.addComponent(Charactor)!;
this.initAnimator();
// this.setSkin("magic");
// this.animator.play("idle", true);
LayerUtil.setNodeLayer(LayerUtil.MAP, this.node);
this.idle();
}
/** 初始化动画 */
protected initAnimator() {
this.spine = this.animator.getComponent(sp.Skeleton)!;
this.spine.setSkin('war');
}
// setState(value: CharactorState): void {
// switch (value) {
// case CharactorState.Idle:
// this.idle();
// break;
// case CharactorState.Run:
// this.walk();
// break;
// }
// }
setSkin(value: string): void {
console.log("RoleSpine setSkin", value);
this.spine.setSkin(value);
}
play(animName: string, loop: boolean): void {
this.spine.setAnimation(0, animName, loop);
}
setAlpha(value: number): void {
var color: Color = this.spine.color;
color.a = 255 * (value / 1);