problem with the counter of a collision between two images
here is my code :
-(void)collision {
if(CGRectIntersectsRect(imageView.frame,centre.frame)){
[imageView removeFromSuperview];
count++;
label.text= [NSString stringWithFormat:@"%d", count];
}
}
- (void)viewDidLoad {
[super viewDidLoad];
[NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(collision) userInfo:nil repeats:YES];
开发者_运维问答 count=0;
scale=1;
}
with this code my count increase of more than one sometimes 34 and sometime 74 or 70 , why ?
Stops the receiver from ever firing again and requests its removal from its run loop.
- (void)invalidate
class reference
helpful question
精彩评论