gpt4 book ai didi

iphone - cocos2d CCMenu 在视网膜设备上的填充很奇怪

转载 作者:行者123 更新时间:2023-11-29 04:36:48 24 4
gpt4 key购买 nike

情况:我正在使用 [(CCMenu*)myMenualignItemsVerticallyWithPadding: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];

最佳答案

已解决:
填充问题是由TexturePacker 中的设置造成的。我将“内部填充”设置为 4px 的值。删除设置解决了问题。请参阅下面的屏幕截图:

enter image description here

关于iphone - cocos2d CCMenu 在视网膜设备上的填充很奇怪,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10969741/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com