我的Cocos2D应用程序使用了许多CCMenuItemSprite用于按钮(例如后退按钮)。当按钮位于风景场景的左半部分时,它无法响应触摸。屏幕右半部分的按钮工作正常。初始化按钮的代码很简单:
CCSprite *normalSprite = [CCSprite spriteWithFile:@"MenuArrowButtonOblongNormal_iPad.png"];
CCSprite *selectedSprite = [CCSprite spriteWithFile:@"MenuArrowButtonOblongSelected_iPad.png"];
CCMenuItemSprite *backButton = [CCMenuItemSprite itemFromNormalSprite:normalSprite
selectedSprite:selectedSprite
target:self
selector:@selector(returnToOptionsMenu)];
if (screenSizeInPixels.width == 1136.0f) {
[backButton setScaleX:0.9375f];
[backButton setScaleY:0.8322f];
buttonHeight = 0.9f;
}
CCMenu *sceneSelectMenu;
sceneSelectMenu = [CCMenu menuWithItems: backButton,nil];
[sceneSelectMenu alignItemsVerticallyWithPadding:screenSize.height * 0.059f];
[sceneSelectMenu setPosition:ccp(screenSize.width*0.15,
screenSize.height * buttonHeight)];
[self addChild:sceneSelectMenu];
// And finally the back button label
CCLabelTTF *backButtonLabel;
backButtonLabel = [CCLabelTTF labelWithString:NSLocalizedString(@"Back", @"Enables user to exit the current screen and view the previous screen")
fontName:@"Marker Felt"
fontSize:scaledFontSize*1.3];
backButtonLabel.color = ccc3(255,255,255);
[backButtonLabel setAnchorPoint:ccp(0.5,0.5)];
backButtonLabel.position = ccp(screenSize.width * (0.14+labelOffset),
screenSize.height * labelHeight);
[self addChild:backButtonLabel z:2];
这是一个使用Cocos2D版本1.1-RC0的旧应用程序。我根据iPhone 6 and 6+ update patch for cocos2d 2.1中建议的更改对此代码进行了多次更新。但这些主要解决分辨率/比例因子问题。
如果没有人见过这个问题,您能否建议我在cocos2D中调查哪些内容以确定触摸未被检测/作用的原因?