Im adding a load of instances of a class to my scene and detecting a collision between them and another object.
All set up and working
if ((firstBody.categoryBitMask & ballCategory) != 0 && (secondBody.categoryBitMask & objectCategory) != 0) {
NSLog(@"Hit");
}
Getting the "Hit" log whenever I get a collision.
How do I now perform an instance method on one of those objects?
Just for reference this is me adding one of the objects.
Ball *ball = [[Ball alloc]init];
ball.position = CGPointMake(spawnPoint.x + arc4random() % 5, spawnPoint.y);
ball.physicsBody = [SKPhysicsBody bodyWithCircleOfRadius:5];
ball.physicsBody.dynamic = YES;
ball.physicsBody.mass = 10;
ball.name = @"ball";
ball.physicsBody.categoryBitMask = ballCategory;
ball.physicsBody.contactTestBitMask = targetCategory | ballCategory;
ball.physicsBody.collisionBitMask = targetCategory | ballCategory | objectCategory;
[self addChild:ball];
It's very simple: