Cocos2Dを使用してiPhoneアプリのスライドアウト設定メニューを作成しました。設定メニューのあるレイヤーをゲームメニューのある別のレイヤーに移動することで、すべてが完全に機能しています...ただし、クリックすることはできます。率直に言って、設定メニューからゲームメニューのメニュー項目を実行したくない;)ユーザー入力に応答しないようにメニュー項目を設定する簡単な方法はありますか?または、設定メニューにシースルーオーバーレイメニュー項目を作成して、タッチを吸収する必要がありますか?
これが私のコードです:
- (void)addButtons: (int) screenSize {
CCMenuItemImage *goPlay = [CCMenuItemImage itemWithNormalImage:@"playButtonUnpressed.png"
selectedImage:@"playButtonPressed.png"
target:self
selector:@selector(onPlay:)];
CCMenuItemImage *goSettings = [CCMenuItemImage itemWithNormalImage:@"settingsButtonUnpressed.png"
selectedImage:@"settingsButtonPressed.png"
target: self
selector:@selector(onSettings:)];
CCMenuItemImage *goFacebook = [CCMenuItemImage itemWithNormalImage:@"facebook.png"
selectedImage:@"facebook.png"
target: self
selector:@selector(onFacebook:)];
CCMenuItemImage *goTwitter = [CCMenuItemImage itemWithNormalImage:@"twitter.png"
selectedImage:@"twitter.png"
target: self
selector:@selector(onTwitter:)];
CCMenuItemImage *goWebsite = [CCMenuItemImage itemWithNormalImage:@"website.png"
selectedImage:@"website.png"
target: self
selector:@selector(onWebsite:)];
CCMenu *play = [CCMenu menuWithItems: goPlay,goSettings,goFacebook,goTwitter,goWebsite,nil];
[self addChild: play];
// Add menu image to menu
play.position = ccp(0,0);
if (self.iPad) {
goPlay.position = ccp(64, 64);
goSettings.position = ccp(128,128);
// Add menu to this scene
}
else if (screenSize < 490){
goPlay.position = ccp(85, 85);
goSettings.position = ccp(235,85);
goFacebook.position = ccp(275,445);
goTwitter.position = ccp(275,402);
goWebsite.position = ccp(275,359);
// Add menu to this scene
}
}
- (void) onSettings: (id) sender{
CGPoint onScreenPoint = ccp(0, 0);
id actionMove = [CCMoveTo actionWithDuration:0.3
position:onScreenPoint];
[_settings runAction:[CCSequence actions:actionMove, nil]];
}
他に何か見る必要がある場合はお知らせください...しかし、上記のコードで解決策を提供できると確信しています:)