Hello,
First I’ll explain what I want to do before seeing the code, the user can click to the PLAY Button and after click, a popup Menu is displayed, the Menu contain 2 MenuItemSprite for play with bot or friend, for the MenuItemImage it’s to display a small background around 2 MenuItemSprite.
The problem is when I want to click on a MenuItemSprite inside the Menu, nothing is happening, but when I set enable the Background to false all is okay without any problem, But I don’t want this solution because I have inside another background (almost transparent). If the user click to this background, he can hide automatically the Menu, so I said set enable the background to false it’ll give another problem conflit between Background (Window) and background (Menu).
Code :
//Background (Scene)
background=Sprite::create(BACKGROUND);
background->setPosition(SonarCocosHelper::UI::GetScreenCenter());
background->setOpacity(0);
this->addChild(background,1);
//Background Menu
MenuItemImage * overlayWindowItem=MenuItemImage::create(GAME_OVER_WINDOW,GAME_OVER_WINDOW,GAME_OVER_WINDOW,NULL);
//overlayWindowItem->setEnabled(false);
//FRIEND ITEM
MenuItemSprite * friendItem=MenuItemSprite::create(Sprite::create(FRIEND_BUTTON), Sprite::create(FRIEND_BUTTON),CC_CALLBACK_1(MenuScene::goToPlay,this));
friendItem->setTag(PLAY_WITH_FRIEND);
friendItem->setPosition(Vec2(-overlayWindowItem->getContentSize().width/4,friendItem->getPositionY()));
//BOT ITEM
MenuItemSprite * botItem=MenuItemSprite::create(Sprite::create(BOT_BUTTON), Sprite::create(BOT_BUTTON),CC_CALLBACK_1(MenuScene::goToPlay,this));
botItem->setTag(PLAY_WITH_BOT);
botItem->setPosition(Vec2(overlayWindowItem->getContentSize().width/4,botItem->getPositionY()));
//menu
menu=Menu::create(overlayWindowItem,friendItem,botItem,NULL);
menu->setPosition(Vec2(SonarCocosHelper::UI::GetScreenCenter().x,SonarCocosHelper::UI::GetScreenCenter().y+screenSize.height));
this->addChild(menu,1);
How I can avoid conflit between MenuItemImage & MenuItemSprite, I want to click on MenuItemSprite, MenuItemImage is just a background.
Thank you,