大佬们,下面这段代码敌人与角色的攻击碰撞,碰撞几次后由takeDamage状态恢复回idle状态,但多碰撞几次后敌人还是idle状态,但碰撞不起效果了是因为什么

onBeginContact(self: Collider2D, other: Collider2D, contact: IPhysics2DContact) {

    if (self && other) {

        if (other.group === Constant.ColliderGroup.PLAYER_ATTACK) {

            switch(other.tag) {

                case Constant.ColliderTag.PLAYER_ATTACK1:

                    if (this.enemyStatus !== Constant.CharStatus.DEATH) {

                        this.hurt(40);

                    }

                    break;

                default:

                    break;

            }

        } else if (other.group === Constant.ColliderGroup.PLAYER) {

            switch(other.tag) {

                case Constant.ColliderTag.PLAYER:

                    contact.disabled = true;

                    break;

                default:

                    break;

            }

        }

    }

}

onEndContact(self: Collider2D, other: Collider2D, contact: IPhysics2DContact) {

    if (other.group === Constant.ColliderGroup.PLAYER) {

        switch(other.tag) {

            case Constant.ColliderTag.PLAYER_ATTACK1:

                break;

            case Constant.ColliderTag.PLAYER:

                contact.disabled = false;

                break;

            default:

                break;

        }

    }

}

   

playDeath() {

    const display = this.ndAni.getComponent(dragonBones.ArmatureDisplay);

    if (!display) return;

    display.armatureName = 'Death';

    display.playAnimation('Death', 1);

    const onComplete = () => {

       

            if (this.hp <= 0) {

                Globals.putNode(this.node);

                console.log('死亡');

            }

       

        display.off(dragonBones.EventObject.COMPLETE, onComplete, this);

    }

    display.on(dragonBones.EventObject.COMPLETE, onComplete, this);

   

}

playAttack() {

    const display = this.ndAni.getComponent(dragonBones.ArmatureDisplay);

    display.armatureName = 'Attack1';

    display.playAnimation('Attack1', 1);

    const callback = this.scheduleOnce(() => {

        this.updateColliderPosition(this.attackCollider, 14);

        this.attackCollider.enabled = true;

    }, 0.7)

    // this.attackCollider.enabled = false;

    const onComplete = () => {

        if (this.hp > 0) this.enemyStatus = Constant.CharStatus.IDLE;

        this.attackCollider.enabled = false;

        this.unschedule(callback);

        display.off(dragonBones.EventObject.COMPLETE, onComplete, this);

    }

   

    display.addEventListener(dragonBones.EventObject.COMPLETE, onComplete, this);

}

updateColliderPosition =(collider: Collider2D, offset: number) => {

    collider.offset.x = this.node.scale.x * offset;

    collider.node.worldPosition = this.node.worldPosition;

}

// 受击状态

playTakedamage() {

    const display = this.ndAni.getComponent(dragonBones.ArmatureDisplay);

    display.armatureName = 'TakeDamage';

    display.playAnimation('TakeDamage', 1);

    const onComplete = () => {

        this.enemyStatus = Constant.CharStatus.IDLE;

        display.off(dragonBones.EventObject.COMPLETE, onComplete, this);

    }

    display.addEventListener(dragonBones.EventObject.COMPLETE, onComplete, this);

}