情況: 我使用[(CCMenu *)MYMENU alignItemsVerticallyWithPadding:4.0F]佈局幾個按鈕(CCMenuItemSprite)垂直。在非視網膜設備上,填充按預期出現,但在模擬器上的視網膜模式下,填充似乎加倍。任何想法爲什麼?的cocos2d CCMenu填充視網膜設備上奇怪
代碼:
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];
好事你解決它! –