Reputation: 649
in my game I have a bingo board, using various defines, the ones relating to this question are;
#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
As it currently is, they work fine on iPhone, however the spacing is not correct on the iPad, and I figured the differences and wrote them next to the defines, however, I am trying to figure out how I can split them to show one set of values for iPhone, and the other for iPad?
Being used here;
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
}
}
}
}
And also being used here;
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];
}
}
}
}
}
Upvotes: 0
Views: 29
Reputation: 24
Heres an idea :)
#define IPAD UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad
#define EXAMPLE (IPAD ? 24 : 35) // IPAD 24, Otherwise 35
Upvotes: 1