开始多次碰撞只需要在if条件里再加个判断即可otherCollider.enabled 为true

蓝调98

1 回复20 浏览

来自课程:CocosCreator3.8入门教程-微信飞机大战

if (otherCollider.getComponent(Reward) && otherCollider.enabled) {//与奖励碰撞
    otherCollider.enabled = false
    otherCollider.getComponent(Sprite).enabled = false
    const rewardType = otherCollider.getComponent(Reward).rewardType
    switch (rewardType) {
        case RewardType.TwoShoot:
            this.shootType = ShootType.TwoShoot
            this.unschedule(this.restOneShoot)
            this.scheduleOnce(this.restOneShoot, 5)
            break

        case RewardType.Boom:
            GameManager.instance.addBoom()
            break
    }
}

全部回复(1)

  • 老师_Jokey 1 楼

    感谢同学提供更多的思路

     

发表回复

登录后可以回复