手动控制spine 动画
This commit is contained in:
@@ -7,8 +7,6 @@
|
||||
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 { ICharactorClip } from "../../map/view/map/charactor/ICharactorClip";
|
||||
import RoleSpineAnimator from "./RoleSpineAnimator";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
@@ -17,55 +15,29 @@ const { ccclass, property } = _decorator;
|
||||
* RPG SPINE角色模型
|
||||
*/
|
||||
@ccclass('RoleSpine')
|
||||
export class RoleSpine extends Component implements ICharactorClip {
|
||||
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();
|
||||
|
||||
LayerUtil.setNodeLayer(LayerUtil.MAP, this.node);
|
||||
this.idle();
|
||||
}
|
||||
|
||||
/** 初始化动画 */
|
||||
protected initAnimator() {
|
||||
this.spine = this.animator.getComponent(sp.Skeleton)!;
|
||||
this.spine.setSkin('war');
|
||||
}
|
||||
|
||||
setPlayer(pos: Vec3) {
|
||||
// var scene = smc.map.MapView.scene;
|
||||
// this.node.parent = scene.entityLayer!.node!;
|
||||
// this.charactor.clip = this;
|
||||
// this.charactor.sceneMap = scene;
|
||||
this.charactor.pos = pos;
|
||||
this.charactor.updateZIndex();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
setDirection(value: CharactorDirection): void {
|
||||
if (value > 4) {
|
||||
this.animator!.node.setScale(-1, 1, 1);
|
||||
}
|
||||
else {
|
||||
this.animator!.node.setScale(1, 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
setState(value: CharactorState): void {
|
||||
switch (value) {
|
||||
case CharactorState.Idle:
|
||||
this.idle();
|
||||
break;
|
||||
case CharactorState.Run:
|
||||
this.walk();
|
||||
break;
|
||||
}
|
||||
}
|
||||
setSkin(value: string): void {
|
||||
this.spine.setSkin(value);
|
||||
}
|
||||
@@ -89,10 +61,10 @@ export class RoleSpine extends Component implements ICharactorClip {
|
||||
}
|
||||
|
||||
walk() {
|
||||
this.animator!.setNumber("Speed", 1);
|
||||
|
||||
}
|
||||
|
||||
idle() {
|
||||
this.animator!.setNumber("Speed", 0);
|
||||
this.animator!.play("idle");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user