当气泡与恒星碰撞时,starCount variabel应该对其自身加1,而仅加1。相反,有时更多。我认为“ starCount + = 1”被调用过几次,但我不知道为什么。
if firstbody.categoryBitMask == PhysicsCategory.star && secondbody.categoryBitMask == PhysicsCategory.bubble{
starCount += 1
firstbody.node?.removeFromParent()
} else if firstbody.categoryBitMask == PhysicsCategory.bubble && secondbody.categoryBitMask == PhysicsCategory.star{
starCount += 1
secondbody.node?.removeFromParent()
}
为什么会这样?