init(rawValue:)
Creates a collision group from a raw value.
Declaration
init(rawValue: UInt32)Parameters
- rawValue:
The raw value of the option set to create. Each bit of rawValue potentially represents an element of the option set, though raw values may include bits that are not defined as distinct values of the OptionSet type.
Discussion
This initializer succeeds even if the value passed as rawValue exceeds the static properties declared as part of the option set. Usually, you will want to create each collision groups setting a different bit flag for each value, so that multiple individual groups can be combined using OptionSet methods.
Here is an example of creating four collision groups using different bitflag values for each one.
let redGroup = CollisionGroup(rawValue: 1 << 0)
let blueGroup = CollisionGroup(rawValue: 1 << 1)
let greenGroup = CollisionGroup(rawValue: 1 << 2)
let yellowGroup = CollisionGroup(rawValue: 1 << 3)