I'm trying to have a button that when pressed, will reset the scene. The button works fine however on the second time, certain nodes are in different positions and physics contacts are being triggered. Here's my code
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
/* Called when a touch begins */
if (inGame == false) {
inGame = true;
gravity = -7;
SKAction *wait = [SKAction waitForDuration:1.5];
SKAction *moveOff = [SKAction moveBy:CGVectorMake(-25000, 0) duration:100];
SKAction *sequence = [SKAction sequence:@[wait, moveOff]];
[startRamp runAction:sequence];
[tapToStart runAction:sequence];
SKSpriteNode *ball = [SKSpriteNode spriteNodeWithImageNamed:@"Ball"];
ball.position = CGPointMake(CGRectGetMaxX(self.frame)/(CGRectGetMaxX(self.frame)/64), CGRectGetMidY(self.frame)*1.3);
ball.scale = CGRectGetMaxX(self.frame)/((CGRectGetMaxX(self.frame)*8));
ball.physicsBody = [SKPhysicsBody bodyWithCircleOfRadius:ball.size.width/2];
ball.physicsBody.categoryBitMask = playerMask;
ball.physicsBody.contactTestBitMask = playerMask2;
[self addChild:ball];
nodeLocation = ball;
ball = nodeLocation;
}
else if (timeCountStart >= 90) gravity *= -1;
else if (moveNextScene == true) {
[self.view presentScene:self.scene transition:[SKTransition doorwayWithDuration:2]];
}
moveNextScene = true;
}