2017-05-04 29 views
0

我有一個賓果遊戲板,使用各種定義,有關這個問題的是;在我的遊戲中試圖分割iPhone和iPad的大小爲遊戲的特定部分

#define BTNNUMBER_SX  43// iPad should be 43 
#define BTNNUMBER_SY  105 // iPad should be 85 
#define BTNNUMBER_DX  47 // iPad should be 27 
#define BTNNUMBER_DY  25 // iPad should be 15 

因爲它目前是,他們的工作罰款iPhone,但是間隔不是在iPad上正確的,我想通了分歧,寫了他們旁邊的定義,但是,我想弄清楚如何我可以將它們拆分爲顯示iPhone的一組值,另一個用於iPad?

在這裏使用;

for (int c = 0; c < _cardNumber; c++) { 
     for (int i = 0; i < 5; i++) { 
      for (int j = 0; j < 5; j++) { 
       if (i == 2 && j == 2) { 
        float x = BTNNUMBER_SX + i * (BTNNUMBER_W + BTNNUMBER_DX); 
        float y = BTNNUMBER_SY + j * (BTNNUMBER_H + BTNNUMBER_DY); 
        float w = BTNNUMBER_W; 
        float h = BTNNUMBER_H; 
        x *= padScale; 
        y *= padScale; 
        w *= padScale; 
        h *= padScale; 
        x += _ivBingoPad[c].frame.origin.x; 
        y += _ivBingoPad[c].frame.origin.y; 

        _btnBingo[c] = [[BingoButton alloc] initWithFrame:CGRectMake(x,y,w,h)]; 
        [_btnBingo[c] setTitle: @"" forState: UIControlStateNormal]; 
        [_btnBingo[c] setImage:[UIImage imageNamed:@"bingo_free_button"] forState: UIControlStateNormal]; 
        [_btnBingo[c] addTarget: self action:@selector(success) forControlEvents: UIControlEventTouchUpInside]; 
        [self.view addSubview: _btnBingo[c]]; 
#ifdef DEVELOPMENT 
        _btnBingo[c].enabled = YES; 
#else 
        _btnBingo[c].enabled = NO; 
#endif 
       } 
      } 
     } 
    } 

也在這裏使用;

if ([MainViewController isPad] == NO) { 
     if (_blUpperScreen) { 
      if (_cardNumber > 2) 
       _btnBingo[2].hidden = true; 
      if (_cardNumber == 4) 
       _btnBingo[3].hidden = true; 
     } 
    } 

    for (int c = 0; c < _cardNumber; c++) { 
     for (int i = 0; i < 5; i++) { 
      for (int j = 0; j < 5; j++) { 
       float x = BTNNUMBER_SX + i * (BTNNUMBER_W + BTNNUMBER_DX); 
       float y = BTNNUMBER_SY + j * (BTNNUMBER_H + BTNNUMBER_DY); 
       float w = BTNNUMBER_W; 
       float h = BTNNUMBER_H; 
       x *= padScale; 
       y *= padScale; 
       w *= padScale; 
       h *= padScale; 
       x += _ivBingoPad[c].frame.origin.x; 
       y += _ivBingoPad[c].frame.origin.y; 

       if (i == 2 && j == 2) { 
       } 
       else { 
        _btnNumberArr[i][j][c] = [[NumberButton alloc] initWithFrame:CGRectMake(x,y,w,h)]; 
        _btnNumberArr[i][j][c].statusImage = [UIImage imageNamed:@"bingocard_select"]; 
        _btnNumberArr[i][j][c].font = [UIFont boldSystemFontOfSize: 40*padScale]; 
        [_btnNumberArr[i][j][c] setTitleColor: [UIColor blackColor] forState: UIControlStateNormal]; 
        [self.view addSubview: _btnNumberArr[i][j][c]]; 
        [_btnNumberArr[i][j][c] addTarget: _btnNumberArr[i][j][c] action:@selector(onClick) forControlEvents: UIControlEventTouchUpInside]; 
        [_btnNumberArr[i][j][c] setParam:_cardRep[c] :_globals :j :i :_bingoChecker :_btnBingo[c]]; 
        if ([BingoCheckerPostageStamp hasPatternXY:_cardRep[c]:j:i] && profile.gameRoom.intValue == GAME_ROOM_POSTAGESTAMP) { 
         [_btnNumberArr[i][j][c] setBackgroundImage:[UIImage imageNamed:@"bingocard_pattern_mark"] forState:UIControlStateNormal]; 
        } 
       } 
      } 
     } 
    } 

回答

1

這裏有一個想法:)

#define IPAD UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad 
 

 
#define EXAMPLE (IPAD ? 24 : 35) // IPAD 24, Otherwise 35

+0

偉大的工程謝謝!雖然我需要購買IPAD?內(支架) – Hypergater