这是我的game.h和game.m错误是粗体。 game.h上没有任何错误。最后,它表示缺少解析需要花括号。还有缺少的标识符。通过game.h跟随游戏.m以粗体显示
@interface Game (){
}
@end METHOD DEFINITION NOT FOUND
@implementation Game METHOD DEFINITION NOT FOUND
-(IBAction)StartGame:(id)sender{
StartGame.hidden = YES;
BlueballMovement = [NSTimer scheduledTimerWithTimeInterval:0.05 target:self selector:@selector(BlueballMoving)
userInfo:nil repeats:YES];
[self PlaceObstacles];
ObstacleMovement = [NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(ObstacleMoving) userInfo:nil repeats:YES];
}
-(void)ObstacleMoving{
ObstacleTop4.center = CGPointMake(ObstacleTop4.center.x, ObstacleTop4.center.y - 1);
ObstacleRight3.center = CGPointMake(ObstacleRight3.center.x, ObstacleRight3.center.y - 1);
ObstacleLeft1.center = CGPointMake(ObstacleLeft1.center.x, ObstacleLeft1.center.y - 1);
ObstacleBottom2.center = CGPointMake(ObstacleBottom2.center.x, ObstacleBottom2.center.y - 1);
ObstacleMiddle5.center = CGPointMake(ObstacleMiddle5.center.x, ObstacleMiddle5.center.y - 1);
if (ObstacleLeft1.center.y < 600) {
[self PlaceObstacles]; }
if (ObstacleBottom2.center.y < 600) {
[self PlaceObstacles]; }
if (ObstacleRight3.center.y < 600) {
[self PlaceObstacles]; }
if (ObstacleTop4.center.y < 600) {
[self PlaceObstacles]; }
if (ObstacleMiddle5.center.y < 600) {
[self PlaceObstacles]; }
} UNDECLARED IDENTIFIER
-(void)PlaceObstacles {
RandomObstacleBottom2Position = arc4random() %350;
RandomObstacleBottom2Position = RandomObstacleBottom2Position - 228;
RandomObstacleLeft1Position = arc4random() %350;
RandomObstacleLeft1Position = RandomObstacleLeft1Position - 228;
RandomObstacleMiddle5Position = arc4random() %350;
RandomObstacleMiddle5Position = RandomObstacleMiddle5Position - 228;
RandomObstacleRight3Position = arc4random() %350;
RandomObstacleRight3Position = RandomObstacleRight3Position - 228;
RandomObstacleTopPosition = arc4random() %350;
RandomObstacleTopPosition = RandomObstacleTopPosition - 228;
}
-(void)BlueballMoving{
Blueball.center = CGPointMake(Blueball.center.x, Blueball.center.y - BlueballRolling);
BlueballRolling = BlueballRolling + 5;
if(BlueballRolling < -10) {
BlueballRolling = -10;
}
if (BlueballRolling > 0) {
Blueball.image = [UIImage imageNamed:@"BluestartingPNG.png"];
}
}
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
BlueballRolling = 25;
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
@end EXPECTED }
GAME.H
#import <UIKit/UIKit.h>
int BlueballRolling;
int RandomObstacleTopPosition;
int RandomObstacleBottom2Position;
int RandomObstacleLeft1Position;
int RandomObstacleRight3Position;
int RandomObstacleMiddle5Position;
@interface Game : UIViewController
{
IBOutlet UIImageView *Blueball;
IBOutlet UIButton *StartGame;
IBOutlet UIImageView *ObstacleLeft1;
IBOutlet UIImageView *ObstacleRight3;
IBOutlet UIImageView *ObstacleTop4;
IBOutlet UIImageView *ObstacleBottom2;
IBOutlet UIImageView *ObstacleMiddle5;
NSTimer *BlueballMovement;
NSTimer *ObstacleMovement;
}
-(IBAction)StartGame:(id)sender;
-(void)BlueballMoving;
-(void)ObstacleMoving;
-(void)PlaceObstacles;
@end
答案 0 :(得分:0)
当Xcode构建您的项目时,它会创建一个文件夹,将您的所有代码编译到该文件夹中的文件中,并将它们链接到您的应用程序中。更改代码时,只需重新创建受影响的文件并再次链接它们。但是,有时可能会出现文件无法更新的故障,导致代码在完全没有错误时出错。按 Shift - 命令 - K (清除)通过清除许多这些缓存和中间体来解决许多这些问题,迫使Xcode重新创建它们。如果问题仍然存在,请按选项 - Shift - 命令 - K (清洁构建文件夹)清除更多。