const int TAG_EXIT = 10000 ; const int TO_MY_HALL = 10001 ; const int RESTART = 10002 ; void GameResult::addButton( const char * name, int tag, float x, float y, const char * txt){ auto b = MenuItemImage::create(name, name, this , menu_sele
const int TAG_EXIT = 10000;
const int TO_MY_HALL = 10001;
const int RESTART = 10002;
void GameResult::addButton(const char* name, int tag, float x, float y, const char* txt)
{
auto b = MenuItemImage::create(name, name, this, menu_selector(GameResult::cb));
TI()->setPos(b, x, y);
b->setTag(tag);
auto m = Menu::create(b, NULL);
m->setPosition(Vec2::ZERO);
addChild(m, 100);
auto _txt = Label::createWithSystemFont(txt, "Arial", 30);
b->addChild(_txt);
_txt->setPosition(b->getContentSize().width/2, b->getContentSize().height/2);
}
void GameResult::cb(Ref* obj)
{
Node* node = dynamic_cast<Node*>(obj);
switch (node->getTag())
{
case TAG_EXIT:
break;
case TO_MY_HALL:
break;
case RESTART:
break;
default:
break;
}
this->setVisible(false);
((GameMenu *)this->getParent())->onResultHide();
}