I am trying to make a game where a ball is moving and the player accumulates points as the game goes on.
I'm using an NSTimer to count the score of the player this way:
- (void)viewDidLoad
{
[super viewDidLoad];
NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(timerCountTest) userInfo:nil repeats:YES];
}
-(void)timerCountTest{
timerCountClassic += 1;
clockLabel.text = [NSString stringWithFormat:@"%i", timerCountClassic];
ballTest.center = CGPointMake(ballTest.center.x -5, ballTest.center.y);
}
The problem is that the ball does not move but the score works. If I however comment out the clockLabel line, the ball will move but the clockLabel wont work of course. When I try placing the line of code that makes the ball move and set the NS Timer to a value of 0.01. The ball moves but almost immediately places the ball in the position it started. It's very strange and I'm not certain why this is occurring. This code worked in Xcode 5 but in Xcode 6 it seems as if the NSTimer isn't working properly or something. Any help would be appreciated, thanks.