/* * @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 } from "cc"; import { LayerUtil } from "../../../../extensions/oops-plugin-framework/assets/core/utils/LayerUtil"; import { smc } from "../../../script/game/common/SingletonModuleComp"; // import Charactor, { CharactorDirection, CharactorState } from "../../map/view/map/charactor/Charactor"; import MonsterSpineAnimator from "./MonsterSpineAnimator"; const { ccclass, property } = _decorator; /** * RPG SPINE角色模型 */ @ccclass('MonsterSpine') export class MonsterSpine extends Component { @property({ type: MonsterSpineAnimator, tooltip: '动画控制器' }) animator: MonsterSpineAnimator = 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); } /** 初始化动画 */ protected initAnimator() { this.spine = this.animator.getComponent(sp.Skeleton)!; // console.log("MonsterSpine initAnimator", this.spine); } // setState(value: CharactorState): void { // switch (value) { // case CharactorState.Idle: // this.idle(); // break; // case CharactorState.Run: // this.walk(); // break; // } // } setSkin(value: string): void { console.log("MonsterSpine 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); this.spine.color = color; } setPos(value: Vec3): void { this.node.position = value; } checkTouch(event: EventTouch): boolean { return false; } onDestroy() { this.node.destroy(); } walk() { } idle() { } }