Sprite-Kit registering multiple collisions for single contact

OK – it would appear that a simple: if bomb == nil {return} is all that’s required. This should be added as follows: let bomb = contact.bodyA.categoryBitMask == category.bomb.rawValue ? contact.bodyA.node : contact.bodyB.node if bomb == nil {return} This works to prevent multiple collisions for a node that you removeFromParent in didBeginContact. If you don;t … Read more

Sprite kit and colorWithPatternImage

iOS working code: CGRect textureSize = CGRectMake(0, 0, 488, 650); CGImageRef backgroundCGImage = [UIImage imageNamed:@”background.png”].CGImage; UIGraphicsBeginImageContext(self.level.worldSize); // use WithOptions to set scale for retina display CGContextRef context = UIGraphicsGetCurrentContext(); CGContextDrawTiledImage(context, textureSize, backgroundCGImage); UIImage *tiledBackground = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); SKTexture *backgroundTexture = [SKTexture textureWithCGImage:tiledBackground.CGImage]; SKSpriteNode *backgroundNode = [SKSpriteNode spriteNodeWithTexture:backgroundTexture]; [self addChild:backgroundNode];