iphone - iPhone5 Button Placement using IF statement? -
i have game whereby button pause supposed on top right hand corner, on iphone 5 3/4 way top, tried manually set cannot work, works, on iphone 3 & 4 not show (so it's ignoring part of if statement)
ccmenuitemsprite* item1 = [ccmenuitemsprite itemwithnormalsprite:[ccsprite spritewithfile:[[maininfo shareinstance] getimagename:@"pause1.png"]] selectedsprite:[ccsprite spritewithfile:[[maininfo shareinstance] getimagename:@"pause2.png"]] target:self selector:@selector(soundoff)]; ccmenu *menu = [ccmenu menuwithitems:item1, nil]; if ( ![[maininfo shareinstance] isipad] ) menu.position = ccp(290, 450); //450 iphone3/4 // else if (is_iphone_5) { // specific iphone 5 menu.position = ccp(290, 530); //450 iphone3/4 }else menu.position = ccp(696, 960); [_bottomframe addchild:menu z:30 tag:1234]; [self updateboard]; }
at top of .m file have following;
#define is_iphone_5 ([uiscreen mainscreen].bounds.size.height == 568.0)
could please correct way write code above?
many thanks
chris
your else statment not enclosed in brackets furthoremore:
cgsize screensize = [[uiscreen mainscreen] bounds].size; if (screensize.height > 480.0f) { /*do iphone 5 stuff here.*/ } else { /*do iphone classic stuff here.*/ }
Comments
Post a Comment