In SpriteKit I wish to assign the contactTestBitMask value to a set of values.
This is the normal way:
sprite.physicsBody?.contactTestBitMask = ColliderType.goal.rawValue | ColliderType.greyBox.rawValue
meaning my sprite notifies me when it comes it contact with these collider types. However my problem is that my collider types will be dynamically changing during gameplay and the sprite contactTestBitMask also needs to be changed. I was thinking of using a set collider types and assigning different sets and appropriated times:
sprite.physicsBody?.contactTestBitMask = SetManager.sharedSetManager.normalSet
In SetManager Class:
enum NormalColliderType:UInt32 {
case greyBox = 0
case enemy = 2
case goal = 4
case coin = 8
}
var currentSet: Set<Int> = []
var normalSet: Set<UInt32> = [NormalColliderType.greyBox.rawValue | NormalColliderType.goal.rawValue]
static let sharedSetManager = SetManager()
Theoretically, its doable but the only error I'm receiving is: "Cannot assign value of type 'Set' to type 'UInt32'" I guess I'm asking how a set can be used as a variable