在这里发生碰撞的计数器是我的代码:问题有两个图像
-(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;
}
与此代码的不止一个,有时34和某个74或70我数增加,为什么?
为什么'计数== 0'?这是错误吗?尝试'count = 0'。并且使用'++ something'而不是'something ++',它会更快。 – HiTECNOLOGYs