I worked on some SpriteKit tutorials. I understand the whole collision problem and checked with NSLog that a collision is being recorded between my two objects. However, for some really strange reason, my sprite is not created (or rather shown) when it was made during didBeginContact.
- (void)didBeginContact:(SKPhysicsContact *)contact
{
uint32_t collision = (contact.bodyA.categoryBitMask | contact.bodyB.categoryBitMask);
if (collision == (CNPhysicsCategoryPlayer | CNPhysicsCategoryRock))
{
NSLog(@"ouch");
SKSpriteNode *bigOuch = [SKSpriteNode spriteNodeWithImageNamed:@"star"];
bigOuch.position = CGPointMake(200, 200);
[self addChild:bigOuch];
}
}
I get an ouch log message, but no sprite appears.
I tried the same thing (creating a sprite) in other parts of my program and had no problems. What am I doing wrong?
source
share