I am learning Sprite Kit and dealing with collisions of objects. I got this snippet of code from the Apple Docs and I am trying to figure out what the &bitwise operator is doing. First time using bitwise. I know the && logic operator evaluates left and right side for a true or false.
Is it checking left and right to make sure both are not equal to 0?
Is it checking left and right to make sure both are not equal to 0?
Code:
static const uint32_t landerCatagory = 0x1;
static const uint32_t rockCatagory = 0x1 << 1;
static const uint32_t photonCatagory = 0x1 << 2;
static const uint32_t edgeCatagory = 0x1 << 3;
-(void)didBeginContact:(SKPhysicsContact *)contact{
SKPhysicsBody *firstBody;
SKPhysicsBody *secondBody;
if (firstBody.categoryBitMask < secondBody.categoryBitMask) {
firstBody = contact.bodyA;
secondBody = contact.bodyB;
}
else{
firstBody = contact.bodyB;
secondBody = contact.bodyA;
}
[B]
if ((firstBody.categoryBitMask & photonCatagory) != 0) [/B]{
NSLog(@"Big bada boom");
}
NSLog(@"contact");
}