在我的代码missing context for method declaration
中,两个 -(void) 语句都出现“”错误,我无法找出原因。
这是我的代码:
- (void)onTimer {
[self checkCollision];
bad.center = CGPointMake(bad.center.x+pos.x,bad.center.y+pos.y);
if(bad.center.x >320 || bad.center.x<0)
pos.x = -pos.x;
if(bad.center.y >480 || bad.center.y<0)
pos.y = -pos.y;
}
- (void) checkCollision {
if (CGRectIntersectsRect(good.frame,bad.frame)) {
[startButton setHidden:NO];
[timer invalidate];
CGRect frame = [good frame];
frame.origin.x = 132.0;
frame.origin.y = 332.0;
[good setFrame:frame];
CGRect frame2 = [good frame];
frame2.origin.x = 125.0;
frame2.origin.y = 70.0;
[bad setFrame:frame2];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Your not fast enough!" message:@"Try again!" delegate:nil cancelButtonTitle:@"Dismiss"otherButtonTitles:nil];
[alert show];
[alert release];
}
@end