假期修改
This commit is contained in:
@@ -16,68 +16,43 @@ const { ccclass, property } = _decorator;
|
||||
*/
|
||||
@ccclass('RoleSpine')
|
||||
export class RoleSpine extends Component {
|
||||
@property({ type: Animation, tooltip: '动画控制器' })
|
||||
animator: Animation = null!;
|
||||
atk_clip: AnimationClip = null!;
|
||||
idle_clip: AnimationClip = null!;
|
||||
move_clip: AnimationClip = null!;
|
||||
dead_clip: AnimationClip = null!;
|
||||
private loop: boolean = true;
|
||||
private spine!: sp.Skeleton;
|
||||
private default:string = "move";
|
||||
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.initAnimator();
|
||||
LayerUtil.setNodeLayer(LayerUtil.MAP, this.node);
|
||||
this.atk_clip = this.animator.clips[1];
|
||||
this.idle_clip = this.animator.clips[0];
|
||||
this.move_clip = this.animator.clips[2];
|
||||
this.dead_clip = this.animator.clips[3];
|
||||
let animation = this.animator.getComponent(Animation);
|
||||
animation.on(Animation.EventType.FINISHED, this.onAnimationEvent, this)
|
||||
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 initAnimator() {
|
||||
this.animator=this.node.getChildByName("hero").getComponent(Animation);
|
||||
// console.log("role view comp init",this.animator);
|
||||
|
||||
}
|
||||
onAnimationEvent(type: Animation.EventType, state: AnimationState){
|
||||
// console.log("onAnimationEvent",type,state);
|
||||
if(type==Animation.EventType.FINISHED){
|
||||
if(state.name==this.atk_clip.name){
|
||||
this.idle();
|
||||
}
|
||||
}
|
||||
}
|
||||
atk() {
|
||||
if(!this.animator.getState(this.atk_clip.name).isPlaying){
|
||||
this.animator.play(this.atk_clip.name);
|
||||
}
|
||||
}
|
||||
|
||||
magic() {
|
||||
protected play(animName: string, loop: boolean) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
checkTouch(event: EventTouch): boolean {
|
||||
return false;
|
||||
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);
|
||||
}
|
||||
|
||||
onDestroy() {
|
||||
this.node.destroy();
|
||||
}
|
||||
|
||||
walk() {
|
||||
|
||||
}
|
||||
|
||||
idle() {
|
||||
if(!this.animator.getState(this.idle_clip.name).isPlaying){
|
||||
this.animator.play(this.idle_clip.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user