添加暴捶英雄,同时修复 endanmbomcom 错误,使用rigid.sleep和rigid.wakeup关闭和启动碰撞检测
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { _decorator, Animation, Collider2D, Component, Node, sp } from 'cc';
|
||||
import { _decorator, Animation, Collider2D, Component, Node, RigidBody2D, sp } from 'cc';
|
||||
import { SkillCom } from './SkillCom';
|
||||
import { BoxSet } from '../common/config/BoxSet';
|
||||
import { Hero } from '../hero/Hero';
|
||||
@@ -9,12 +9,17 @@ export class EndAnmBomCom extends Component {
|
||||
time:number = 0
|
||||
base:SkillCom = null
|
||||
collider:Collider2D = null
|
||||
rigid:RigidBody2D= null
|
||||
is_complete:boolean = false
|
||||
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
|
||||
this.rigid = this.getComponent(RigidBody2D);
|
||||
console.log("collider",this.collider,this.rigid)
|
||||
this.rigid.sleep()
|
||||
// this.collider.enabled = false
|
||||
// if(this.base.box_group ==BoxSet.HERO) this.collider.group = BoxSet.MONSTER
|
||||
// if(this.base.box_group ==BoxSet.MONSTER) this.collider.group = BoxSet.HERO
|
||||
|
||||
if(this.node.getComponent(Animation)){
|
||||
let anim = this.node.getComponent(Animation);
|
||||
@@ -29,16 +34,38 @@ export class EndAnmBomCom extends Component {
|
||||
this.onAnimationFinished()
|
||||
console.log("[track %s][animation %s] complete: %s", trackEntry.trackIndex);
|
||||
});
|
||||
spine.setEventListener((trackEntry, event:any) => {
|
||||
this.onEnvent(event)
|
||||
// console.log("[track %s][animation %s] event: %s", trackEntry.trackIndex, event.data.name, event.intValue);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
onAnimationFinished(){
|
||||
this.collider.group = this.base.box_group
|
||||
this.node.active=false
|
||||
this.node.active=true
|
||||
if(!this.is_complete){
|
||||
// this.collider.group = this.base.box_group
|
||||
// this.node.active=false
|
||||
// this.node.active=true
|
||||
this.rigid.wakeUp()
|
||||
// this.collider.enabled = true
|
||||
console.log("动画结束,开始伤害")
|
||||
}
|
||||
|
||||
this.base.is_destroy = true
|
||||
|
||||
}
|
||||
onEnvent(event:any){
|
||||
if(event.data.name == "atk_event"){
|
||||
// this.collider.group = this.base.box_group
|
||||
// this.node.active=false
|
||||
// this.node.active=true
|
||||
this.rigid.wakeUp()
|
||||
// this.collider.enabled = true
|
||||
console.log("onEnvent,开始伤害",event)
|
||||
this.is_complete=true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user