2

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]];
}

他に何か見る必要がある場合はお知らせください...しかし、上記のコードで解決策を提供できると確信しています:)

4

2 に答える 2

1

ゲームレイヤーメニューのチェックでブールチェックを作成して、それらが触れたかどうかを確認できます。たとえば、CCMenusを使用しているので、セレクター内に追加するだけです。

if(!settingsMenuOut)//checks to see if settingsMenuOut (a bool) is false,
                    //if its true it won't do whatever it normally would.
{ 
   //do the menu stuff
}
于 2012-10-08T01:13:53.583 に答える
0

メニュー自体のisTouchEnabledを変更することで、これを解決しました。

e.g.

//ENABLE when settings displayed
settingsChoiceMenu.isTouchEnabled = TRUE; 

//DISABLE when going back to main scene
settingsChoiceMenu.isTouchEnabled = FALSE;
于 2013-12-03T10:34:41.627 に答える