2014-03-25 48 views
1

* 這是整個代碼:) 我一直在嘗試修復此問題一個小時,但我仍然無法完成。 我會很高興,如果有人可以幫助我:) 仍然不能使UI_USER_INTERFACE_IDIOM代碼工作*if(UI_USER_INTERFACE_IDIOM()== UIUserInterfaceIdiomPhone)

#import "ViewController.h" 

@interface ViewController() 

@end 

@implementation ViewController 


-(void)Collision{ 


if (CGRectIntersectsRect(Heli.frame, Obstacle.frame)) { 
    [self EndGame]; 
} 

if (CGRectIntersectsRect(Heli.frame, Obstacle2.frame)) { 
    [self EndGame]; 
} 

if (CGRectIntersectsRect(Heli.frame, Bottom1.frame)) { 
    [self EndGame]; 
} 

if (CGRectIntersectsRect(Heli.frame, Top1.frame)) { 
    [self EndGame]; 
} 





} 


-(void)EndGame{ 

if (Scorenumber > HighScore) { 
    HighScore = Scorenumber; 
    [[NSUserDefaults standardUserDefaults] setInteger:HighScore  
forKey:@"HighScoreSaved"]; 
} 


Heli.hidden = YES; 
[timer invalidate]; 
[Scorer invalidate]; 


[self performSelector:@selector(NewGame) withObject: nil afterDelay:2]; 

} 


-(void)NewGame{ 
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) { 
    // For iPhone 

Bottom1.hidden = YES; 
Top1.hidden = YES; 
Obstacle.hidden = YES; 
Obstacle2.hidden = YES; 
corona.hidden = YES; 

Intro1.hidden = NO; 
Intro2.hidden = NO; 
Intro3.hidden = NO; 

Heli.hidden = NO; 
Heli.center = CGPointMake(88, 286); 
Heli.image = [UIImage imageNamed:@"buss til app opp.png"]; 

Start = YES; 
Scorenumber = 0; 
Score.text = [NSString stringWithFormat:@"Score: 0"]; 
Intro3.text = [NSString stringWithFormat:@"HighScore: %i", HighScore]; 


} 
} else{ 
    // For iPad 
    Bottom1.hidden = YES; 
    Top1.hidden = YES; 
    Obstacle.hidden = YES; 
    Obstacle2.hidden = YES; 
    corona.hidden = YES; 

    Intro1.hidden = NO; 
    Intro2.hidden = NO; 
    Intro3.hidden = NO; 

    Heli.hidden = NO; 
    Heli.center = CGPointMake(153, 515); 
    Heli.image = [UIImage imageNamed:@"buss til app opp.png"]; 

    Start = YES; 
    Scorenumber = 0; 
    Score.text = [NSString stringWithFormat:@"Score: 0"]; 
    Intro3.text = [NSString stringWithFormat:@"HighScore: %i", HighScore]; 
+0

什麼是行前 – Kevin

+0

嘗試添加多一點。代碼,它可能會給我們更好的見解 – ArthurChamz

回答

1

只要看看下面的代碼:

-(void)NewGame{ 
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) { 
    // For iPhone 

Bottom1.hidden = YES; 
Top1.hidden = YES; 
Obstacle.hidden = YES; 
Obstacle2.hidden = YES; 
corona.hidden = YES; 

Intro1.hidden = NO; 
Intro2.hidden = NO; 
Intro3.hidden = NO; 

Heli.hidden = NO; 
Heli.center = CGPointMake(88, 286); 
Heli.image = [UIImage imageNamed:@"buss til app opp.png"]; 

Start = YES; 
Scorenumber = 0; 
Score.text = [NSString stringWithFormat:@"Score: 0"]; 
Intro3.text = [NSString stringWithFormat:@"HighScore: %i", HighScore]; 


} 
} else{ 

看 - 「}。 「之前的符號」} else{「是錯誤的。這是對的

if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) { 

開放建設,讓「別人」是「獨立 - 這是錯誤的 嘗試刪除這個」 }

+0

非常感謝! 它的工作;) –

+0

歡迎您:) –