情况: 我正在使用 [(CCMenu*)myMenu alignItemsVerticallyWithPadding:4.0f] 垂直布局几个按钮 (CCMenuItemSprite)。在非视网膜设备上,填充按预期显示,但在模拟器上的视网膜模式下,填充似乎加倍。关于为什么的任何想法?
代码:
CCMenuItemSprite *itemPlay = [CCMenuItemSprite itemFromNormalSprite:[CCSprite spriteWithSpriteFrameName:@"play.png"] selectedSprite:nil target:self selector:@selector(goPlay:)];
CCMenuItemSprite *itemHowto = [CCMenuItemSprite itemFromNormalSprite:[CCSprite spriteWithSpriteFrameName:@"howto.png"] selectedSprite:nil target:self selector:@selector(goHowto:)];
CCMenuItemSprite *itemSettings = [CCMenuItemSprite itemFromNormalSprite:[CCSprite spriteWithSpriteFrameName:@"settings.png"] selectedSprite:nil target:self selector:@selector(goSettings:)];
CCMenuItemSprite *itemHelp = [CCMenuItemSprite itemFromNormalSprite:[CCSprite spriteWithSpriteFrameName:@"help.png"] selectedSprite:nil target:self selector:@selector(goHelp:)];
CCMenu *myMenu = [CCMenu menuWithItems:itemPlay,itemHowto,itemSettings,itemHelp, nil];
myMenu.position = ccp(160.0f,216.0f);
[myMenu alignItemsVerticallyWithPadding:4.0f];
[self addChild: myMenu z:10];
更新: 我不想做这样的事情,但如果没有更好的解决方案我会这样做:
float padding = 4.0f;
// flag stored in app delegate to know whether we are retina
if([[AppDelegate sharedAppDelegate] isRetina])padding = (2.0f);
CCMenu *myMenu = [CCMenu menuWithItems:itemPlay,itemHowto,itemSettings,itemHelp, nil];
myMenu.position = ccp(160.0f,216.0f);
[myMenu alignItemsVerticallyWithPadding:padding];
[self addChild: myMenu z:10];