I have a background sprite that I would like to give physics body.
background.physicsBody = [SKPhysicsBody bodyWithRectangleOfSize:CGSizeMake(screenWidth , screenHeight)];
The problem is that the sprites are within the screen bounds and Im trying to detected collision with those sprites when they hit the edge of the screen. Instead its automatically detecting collision because my sprites are already within the physics body of the background. What do I do?
Update:Above question is answered for me now I have another issue. Its detecting contact right way and it has to do with my size and position of background can someone please help me.
//init several sizes used in all scene
screenRect = [[UIScreen mainScreen] bounds];
screenHeight = screenRect.size.height;
screenWidth = screenRect.size.width;
//set background
self.background = [SKSpriteNode spriteNodeWithImageNamed:@"GameBG3.5inchN.png"];
self.background.size = CGSizeMake(screenHeight, screenWidth);
self.background.position = CGPointMake(self.frame.size.width/2, self.frame.size.height/2);
//add pphysics body
self.background.physicsBody = [SKPhysicsBody bodyWithEdgeLoopFromRect:screenRect]; // 1
self.background.physicsBody.dynamic = YES; // 2
self.background.physicsBody.categoryBitMask = screenEdge; // 3
self.background.physicsBody.contactTestBitMask = cd | floppy; // 4
self.background.physicsBody.collisionBitMask = 0; // 5
[self addChild:self.background];
Answer: The problem was where it init my sizes the game is landscape but values were portrait