技能改spine 怪物增加
This commit is contained in:
42
assets/script/game/skills/EndAnmBomCom.ts
Normal file
42
assets/script/game/skills/EndAnmBomCom.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import { _decorator, Animation, Collider2D, Component, Node, sp } from 'cc';
|
||||
import { SkillCom } from './SkillCom';
|
||||
import { BoxSet } from '../common/config/BoxSet';
|
||||
import { Hero } from '../hero/Hero';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('EndAnmBomCom')
|
||||
export class EndAnmBomCom extends Component {
|
||||
time:number = 0
|
||||
base:SkillCom = null
|
||||
collider:Collider2D = null
|
||||
start() {
|
||||
this.base =this.node.getComponent(SkillCom)
|
||||
this.collider = this.getComponent(Collider2D);
|
||||
console.log("collider",this.collider)
|
||||
if(this.base.box_group ==BoxSet.HERO) this.collider.group = BoxSet.MONSTER
|
||||
if(this.base.box_group ==BoxSet.MONSTER) this.collider.group = BoxSet.HERO
|
||||
|
||||
let anim = this.node.getComponent(Animation);
|
||||
if(anim){
|
||||
console.log("has anim",anim)
|
||||
anim.on(Animation.EventType.FINISHED, this.onAnimationFinished, this);
|
||||
}
|
||||
var spine = this.node.getChildByName('anm').getComponent('sp.Skeleton') as sp.Skeleton;
|
||||
if(spine){
|
||||
console.log("has spine",spine)
|
||||
spine.setCompleteListener((trackEntry) => {
|
||||
this.onAnimationFinished()
|
||||
console.log("[track %s][animation %s] complete: %s", trackEntry.trackIndex);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
onAnimationFinished(){
|
||||
this.collider.group = this.base.box_group
|
||||
this.node.active=false
|
||||
this.node.active=true
|
||||
this.base.is_destroy = true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user