【发布时间】:2011-09-28 20:35:55
【问题描述】:
这是我的代码:
-(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,为什么?
【问题讨论】:
-
为什么是
count==0?是错误吗?试试count=0。并且也使用++something而不是something++,它更快。
标签: iphone xcode timer uiimageview collision-detection