I am new to programming and am currently studying a simple game file written in swift provided by Jeoy Devilla.
One thing I can't understand is why he assigns UInt32 values to category collisions:
// Physics body category bitmasks
// ------------------------------
// We'll use these to determine missle-alien collisions
private let missileCategory: UInt32 = 0x1 << 0 // 00000000000000000000000000000001 in binary
private let alienCategory: UInt32 = 0x1 << 1 // 00000000000000000000000000000010 in binary
I'm trying to figure out why "UInt32 - 0x1 << 0...is used in this situation, and examples of other situations that it is used in. Do people do this anytime they want to assign a variable some arbitrary number? Do they do this to ensure this value will never be accidentally be repeated by another object?
link to Game code: http://www.globalnerdy.com/2014/08/10/a-simple-shoot-em-up-game-with-sprite-kit-and-swift-part-one-last-things-first-the-complete-project/
Thanks!