I have tested my app thoroughly on my device with no crashes, the game runs great. However, on my friends device and a few others, it is crashing at the same point. After running the app on my friends device I get this exception: EXC_BAD_ACCESS, with no error message in the console. And my call stack is the screenshot I attached below:
Why is this happening on one device, but not others? Perhaps it's because of different iOS versions but I would like to solve this.
Also, here is the code I am running:
I create an SKAction to resuse. This action shoots razors across the screen for you to dodge it. It always seems to crash either 2-3 razors in..
SKAction Creation:
CGFloat distanceToMoveArrow = self.frame.size.width + (_razorTexture.size.width*4);
SKAction* moveArrow = [SKAction moveByX:-distanceToMoveArrow y:0 duration:0.001 * distanceToMoveArrow];
SKAction* removeArrow = [SKAction removeFromParent];
_moveAndRemoveArrow = [SKAction sequence:@[moveArrow, removeArrow]];
Shooting the Razors:
NSLog(@"Arrow Shot");
SKNode* razorGroup = [SKNode node];
razorGroup.position = CGPointMake( self.frame.size.width + _razorTexture.size.width, 0 );
SKSpriteNode* razor = [SKSpriteNode spriteNodeWithTexture:_razorTexture];
razor.position = CGPointMake( 0, _bird.position.y);
razor.physicsBody = [SKPhysicsBody bodyWithCircleOfRadius:_razorTexture.size.width/2];
razor.physicsBody.dynamic = NO;
razor.physicsBody.categoryBitMask = wallCategory;
razor.physicsBody.contactTestBitMask = birdCategory;
[razorGroup addChild:razor];
[razorGroup runAction:_moveAndRemoveArrow];
[_obstacles addChild:razorGroup];
[self runAction:[SKAction playSoundFileNamed:@"razor-sound.wav" waitForCompletion:NO] withKey:@"RazorSound"];
FYI - This seems to only be happening on iOS 7
Solved it. The problem was:
[self runAction:[SKAction playSoundFileNamed:@"razor-sound.wav" waitForCompletion:NO] withKey:@"RazorSound"];
It was running multiple at the same time, so after I removed the 'withKey' it all worked perfectly.. Must be a weird bug in iOS 7.