bool PopupLanguage::init()
{
	bool ret = CCScene::init();

	extension::UILayer* ul = extension::UILayer::create();
	extension::GUIReader reader;
	ul->addWidget(reader.widgetFromJsonFile("MainMenu/LangSelect.ExportJson"));
	addChild(ul);

	extension::UIWidget* button;

	button = ul->getWidgetByName("popup_button_cancel");
	if (button)
	{
		button->addTouchEventListener(this, toucheventselector(PopupLanguage::_onCancel));
	}

	button = ul->getWidgetByName("button_en");
	if (button)
	{
		button->addTouchEventListener(this, toucheventselector(PopupLanguage::_onLangEn));
	}
	button = ul->getWidgetByName("button_ru");
	if (button)
	{
		button->addTouchEventListener(this, toucheventselector(PopupLanguage::_onLangRu));
	}

	return ret;
}
bool UIScrollViewTest_ScrollToPercentBothDirection_Bounce_Editor::init()
{
    if (UIScene_Editor::init())
    {
        _layout = static_cast<Layout*>(GUIReader::shareReader()->widgetFromJsonFile("cocosgui/UITest/UITest.json"));
        _touchGroup->addWidget(_layout);
        CCSize screenSize = CCDirector::sharedDirector()->getWinSize();
        CCSize rootSize = _layout->getSize();
        _touchGroup->setPosition(CCPoint((screenSize.width - rootSize.width) / 2,
                                        (screenSize.height - rootSize.height) / 2));
        
        Layout* root = static_cast<Layout*>(_touchGroup->getWidgetByName("root_Panel"));
        
        ui::Label* back_label = static_cast<ui::Label*>(UIHelper::seekWidgetByName(root, "back"));
        back_label->addTouchEventListener(this, toucheventselector(UIScene_Editor::toGUIEditorTestScene));
        
        _sceneTitle = static_cast<ui::Label*>(UIHelper::seekWidgetByName(root, "UItest"));
        
        Button* left_button = static_cast<Button*>(UIHelper::seekWidgetByName(root, "left_Button"));
        left_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::previousCallback));
        
        Button* middle_button = static_cast<Button*>(UIHelper::seekWidgetByName(root, "middle_Button"));
        middle_button->setVisible(false);
        
        Button* right_button = static_cast<Button*>(UIHelper::seekWidgetByName(root, "right_Button"));
        right_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::nextCallback));
        
        return true;
    }
    
    return false;
}
Exemple #3
0
bool Dialog::init()
{
    Layer::init();
    
    m_pUILayer = Layer::create();
    
    m_pRootLayer = dynamic_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("Scenes/Dialog.ExportJson"));
    m_pUILayer->addChild(m_pRootLayer);
    
    m_pLeft = initUIButton(LEFT, toucheventselector(Dialog::onButton), m_pRootLayer, this);
    m_pRight = initUIButton(RIGHT, toucheventselector(Dialog::onButton), m_pRootLayer, this);
    
    m_pTxt = (Label*)m_pRootLayer->getChildByTag(TEXT);
    
    m_pLeftBtnOldPoint = m_pLeft->getPosition();
    
    addChild(m_pUILayer);
    
    auto screenSize = Director::getInstance()->getWinSize();
    auto rootSize = m_pRootLayer->getSize();
    setPosition(Point((screenSize.width - rootSize.width) / 2,
                      (screenSize.height - rootSize.height) / 2));
    
    return true;
    
}
Exemple #4
0
bool DetailScene::init()
{
    if (CCLayer::init())
    {
        _uiLayer = Layer::create();
        addChild(_uiLayer);
        
        _widget = dynamic_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("Scenes/DetailScene.ExportJson"));
        _uiLayer->addChild(_widget);
        
        auto screenSize = CCDirector::getInstance()->getWinSize();
        auto rootSize = _widget->getSize();
        _uiLayer->setPosition(Point((screenSize.width - rootSize.width) / 2,
                                    (screenSize.height - rootSize.height) / 2));
        
        btnOK = initUIButton(OK, toucheventselector(DetailScene::onButton), _widget, this);
        btnCancel = initUIButton(CANCEL, toucheventselector(DetailScene::onButton), _widget, this);
        btnFrequency = initUIButton(FREQUENCY, toucheventselector(DetailScene::onButton), _widget, this);
        txtMissionDetail = static_cast<TextField*>(_widget->getChildByTag(MISSION_DETAIL));
        txtMissionName = static_cast<Text*>(_widget->getChildByTag(MISSION_NAME));
        
        Mission *mission = xMissionPool->_vMissions.at(xMissionPool->_iTodayIdx);
        txtMissionName->setText(mission->sName);
        
        return true;
    }
    return false;
}
bool AheadChapter::init()
{
    if (!CCLayerRGBA::init()) return false;
    
    _aUILayer = UILayer::create();
    this->addChild(_aUILayer);
    
    _ahead_root = static_cast<Layout *>(CCUIHELPER->createWidgetFromJsonFile(CG_GamePathes[kAheadChapter].c_str()));
    _aUILayer->addWidget(_ahead_root);
    
    UIButton *startButt = static_cast<UIButton *>(_ahead_root->getChildByName("start_butt"));
    startButt->setTouchEnable(true);
    startButt->addTouchEventListener(this, toucheventselector(AheadChapter::startGame));
    
    UIButton *resetButt = static_cast<UIButton *>(_ahead_root->getChildByName("reset_butt"));
    resetButt->setTouchEnable(true);
    resetButt->addTouchEventListener(this, toucheventselector(AheadChapter::reSetGame));
    
    UIButton *settingButt = static_cast<UIButton *>(_ahead_root->getChildByName("setting_butt"));
    settingButt->setTouchEnable(true);
    settingButt->addTouchEventListener(this, toucheventselector(AheadChapter::settingGame));
    
    UIImageView *map_image = static_cast<UIImageView *>(_ahead_root->getChildByName("gMap_image"));
    map_image->setTouchEnable(true);
    map_image->addTouchEventListener(this, toucheventselector(AheadChapter::enterAcountManager));
    
    return true;
}
Exemple #6
0
bool MainMenu::init(void)
{
    if ( !Layer::init() )
    {
        return false;
    }

	_uiLayer = Layer::create();
	_uiLayer->setPosition(Point(D_display.getLeftBottom()));
	addChild(_uiLayer);

	auto spBg = Sprite::create("images/mainmenu_bg.jpg");
	spBg->setPosition(D_display.getCenterPoint());
	_uiLayer->addChild(spBg);


	auto btnStart = Button::create();
    btnStart->setTouchEnabled(true);
    btnStart->loadTextures("images/btn_start.png", "", "");
	btnStart->setPosition(Point(D_display.cx, D_display.cy+43));
	btnStart->setTag(1);
    btnStart->addTouchEventListener(this, toucheventselector(MainMenu::touchEvent));
    _uiLayer->addChild(btnStart);

	auto btnExit = Button::create();
    btnExit->setTouchEnabled(true);
    btnExit->loadTextures("images/btn_exit.png", "", "");
	btnExit->setPosition(Point(D_display.cx, D_display.cy-43));
    btnExit->addTouchEventListener(this, toucheventselector(MainMenu::touchEvent));
	btnExit->setTag(2);
    _uiLayer->addChild(btnExit); 

	return true;
}
Exemple #7
0
bool PhotoLayer::init()
{
    //////////////////////////////
    // 1. super init first
    if ( !Layer::init() )
    {
        return false;
    }
    
    /////////////////////////////////
    Widget *node = cocostudio::GUIReader::getInstance()->widgetFromJsonFile("ElfYourSelfUi/ElfYourSelfUi_4.ExportJson");
	if (node == nullptr)
	{
		return nullptr;
	}
    
    Button* btnBack = (Button*)node->getChildByName("btnBack");
    btnBack->addTouchEventListener(this, toucheventselector(PhotoLayer::goBack));

    Button* okBtn = (Button*)node->getChildByName("okBtn");
    okBtn->addTouchEventListener(this, toucheventselector(PhotoLayer::changeOk));
    
    this->head = (ImageView*)node->getChildByName("head");
    this->headBg = (ImageView*)node->getChildByName("Image_4");
    touchId1 = -1;
    touchId2 = -1;
    
    this->addChild(node, 0, 1);
    
    return true;
}
bool LoginLayer::init()
{
	if (!Layer::init())
	{
		return false;
	}

	_layerout = GUIReader::getInstance()->widgetFromJsonFile("login/DemoLogin.json");
	this->addChild(_layerout);

	_closeButton = static_cast<ui::Button*>(_layerout->getChildByName("close_Button"));
	_closeButton->addTouchEventListener(this,toucheventselector(LoginLayer::closeButtonCheck));

	_loginButton = static_cast<ui::Button*>(_layerout->getChildByName("login_Button"));
	_loginButton->addTouchEventListener(this, toucheventselector(LoginLayer::loginButtonCheck));

	_userNameTextField = static_cast<ui::TextField*>(_layerout->getChildByName("name_TextField"));
	_userNameTextField->setText("test");

	_passwordTextField01 = static_cast<ui::TextField*>(_layerout->getChildByName("password_TextField"));
	_passwordTextField01->setText("test");

	_passwordTextField02 = static_cast<ui::TextField*>(_layerout->getChildByName("confirm_TextField"));
	_passwordTextField02->setText("test");


	_loginButtonText = static_cast<ui::TextBMFont*>(_loginButton->getChildByName("login_LabelBMFont"));
	_loginButtonText->setText("test");
	
	
	//KeyboardNotificationLayer* keyboradLayer = TextFieldTTFDefaultTest::create();
	//this->addKeyboardNotificationLayer(keyboradLayer);

	return true;
}
bool CMainUIFight::InitSkillBtns()
{
	m_NormalAtk.btn = (Button*)Helper::seekWidgetByName(m_pWidget,"NormalAtk");
	m_NormalAtk.btn->setTag(Normal_Attack_ID);
	m_NormalAtk.btn->addTouchEventListener(this,toucheventselector(CMainUIFight::ClickSkill));
	Size size = m_NormalAtk.btn->getSize();
	m_NormalAtk.cd = CdCtrol::create(skill_cd_path);
	m_NormalAtk.cd->setSize(size-Size(10,10));
	m_NormalAtk.cd->setPosition(Point(size.width/2,size.height/2));
	m_NormalAtk.btn->addChild(m_NormalAtk.cd);

	for (int i=0; i<Skill_Max_Num; ++i)
	{
		m_SkillBtns[i].btn = (Button*)Helper::seekWidgetByName(m_pWidget,CCString::createWithFormat("Skill_%d",i)->getCString());
		m_SkillBtns[i].lock = (ImageView*)Helper::seekWidgetByName(m_pWidget,CCString::createWithFormat("LockImg_%d",i)->getCString());
		m_SkillBtns[i].desc = (Text*)Helper::seekWidgetByName(m_pWidget,CCString::createWithFormat("UnlockDesc_%d",i)->getCString());
		m_SkillBtns[i].icon = (ImageView*)Helper::seekWidgetByName(m_pWidget,CCString::createWithFormat("Icon_%d",i)->getCString());

		m_SkillBtns[i].btn->addTouchEventListener(this,toucheventselector(CMainUIFight::ClickSkill));

		Size size = m_SkillBtns[i].icon->getSize();
		m_SkillBtns[i].cd = CdCtrol::create(skill_cd_path);
		m_SkillBtns[i].cd->setPosition(Point(size.width/2,size.height/2));
		m_SkillBtns[i].cd->setSize(size);
		m_SkillBtns[i].icon->addChild(m_SkillBtns[i].cd);

		m_SkillBtns[i].enable = false;
	}

	return true;
}
Exemple #10
0
bool PreActionBar::initWithLayer(cocos2d::Node* node)
{
	do 
	{
		m_dMinCall = 0;



		//让或弃
		m_pMenuItemCheckOrFold =  static_cast<Button*>(Tools::getWidgetByName(node,"gt_bt_preactionbar_ranghuoqi"));
		m_pMenuItemCheckOrFold->addTouchEventListener(this,toucheventselector(PreActionBar::onMenuItemSelected) ) ;
		//自动让牌
		m_pMenuItemCall =  static_cast<Button*>(Tools::getWidgetByName(node,"gt_bt_preactionbar_autorangpai"));
		m_pMenuItemCall->addTouchEventListener(this,toucheventselector(PreActionBar::onMenuItemSelected) ) ;	
		//自动跟住
		m_pMenuItemCallAny =  static_cast<Button*>(Tools::getWidgetByName(node,"gt_bt_preactionbar_autogengzhu"));
		m_pMenuItemCallAny->addTouchEventListener(this,toucheventselector(PreActionBar::onMenuItemSelected) ) ;


		m_pMenuItemCheckOrFoldText =  static_cast<Text*>(Tools::getWidgetByName(node,"gt_text_preactionbar_ranghuoqi"));
		m_pMenuItemCallText =  static_cast<Text*>(Tools::getWidgetByName(node,"gt_text_preactionbar_rautorangpai"));
		m_pMenuItemCallAnyText =  static_cast<Text*>(Tools::getWidgetByName(node,"gt_text_preactionbar_aotugengzhu"));



		setVisible(false) ;
		return true;

	} while (0);
	return false ;
}
// on "init" you need to initialize your instance
bool HelloWorld::init()
{
    //////////////////////////////
    // 1. super init first
    if ( !CCLayer::init() )
    {
        return false;
    }
    
    CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
    CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();

    /////////////////////////////
    // 2. add a menu item with "X" image, which is clicked to quit the program
    //    you may modify it.

    // add a "close" icon to exit the progress. it's an autorelease object
    CCMenuItemImage *pCloseItem = CCMenuItemImage::create(
                                        "CloseNormal.png",
                                        "CloseSelected.png",
                                        this,
                                        menu_selector(HelloWorld::menuCloseCallback));
    
	pCloseItem->setPosition(ccp(origin.x + visibleSize.width - pCloseItem->getContentSize().width/2 ,
                                origin.y + pCloseItem->getContentSize().height/2));

    // create menu, it's an autorelease object
    CCMenu* pMenu = CCMenu::create(pCloseItem, NULL);
    pMenu->setPosition(CCPointZero);
    this->addChild(pMenu, 1);

    /////////////////////////////
    // 3. add your codes below...
    CCNode* gameScene = SceneReader::sharedSceneReader()->createNodeWithSceneFile("DemoCowboy.json");
    addChild(gameScene);
    
    //Create player
    CCNode* playerNode = gameScene->getChildByTag(10004);
    player = new Player(playerNode);
    
    //Assign callbacks to the buttons
    CCNode* uiNode = gameScene->getChildByTag(10005);
    UILayer* ui = (UILayer*)uiNode->getComponent("GUIComponent")->getNode();
    
    UIButton* btnLeft = (UIButton*)ui->getWidgetByName("LeftButton");
    btnLeft->addTouchEventListener(this, toucheventselector(HelloWorld::onMoveLeft));
    
    UIButton* btnRight = (UIButton*)ui->getWidgetByName("RightButton");
    btnRight->addTouchEventListener(this, toucheventselector(HelloWorld::onMoveRight));
    
    UIButton* btnFire = (UIButton*)ui->getWidgetByName("FireButton");
//    btnFire->addReleaseEvent(this, coco_releaseselector(HelloWorld::onFire));
    btnFire->addTouchEventListener(this, toucheventselector(HelloWorld::onFire));
    
    //Enable update loop
    this->scheduleUpdate();
    
    return true;
}
void MissInfoDetailMediator::initButton()
{
	UtilCocostudio::getInstance()->addEventRelease(this,toucheventselector(MissInfoDetailMediator::callback),"Button_65",downmenuToolbarUi);
	//ui->getChildByName("Button_134");
	UtilCocostudio::getInstance()->addEventRelease(this,toucheventselector(MissInfoDetailMediator::callback),"Button_102_0_0",ui);
	//UtilCocostudio::getInstance()->addEventRelease(this,toucheventselector(MissInfoDetailMediator::callback),"login_Button",ui);

}
Exemple #13
0
void PlayScene::ShowProperty(bool visiable) {
  if(visiable) {
    char b[8] = {};
    sprintf(b, "%d", stageid_+2);
    Finger::Instance().Show(ui_layer_, this, toucheventselector(PlayScene::onUseFinger));
    Replay::Instance().Show(ui_layer_, this, toucheventselector(PlayScene::onUseReplay), b);
  } else {
    Finger::Instance().Disappear(ui_layer_);
    Replay::Instance().Disappear(ui_layer_);
  }
}
Exemple #14
0
void PlayScene::onEnter() {
  CCScene::onEnter();

  CCLOG("%s", __FUNCTION__);
  // load ui
  ui_layer_ = UILayer::create();
  ui_layer_text_ = UILayer::create();
  char path[1024];
  snprintf(path, 1024, "MainScene/GirlScene%d.json",
           stageid_);

  Layout *layout = dynamic_cast<Layout*>(CCUIHELPER->createWidgetFromJsonFile(path));
  ui_layer_->addWidget(layout);

  card_mgr_.CreateLayer(this);
  this->addChild(ui_layer_, 0, 100);
  this->addChild(card_mgr_.card_layer(), 1, 101);
  this->addChild(ui_layer_text_, 2, 100);

  card_mgr_.Init(stageid_);

  UIButton *btn = (UIButton *)ui_layer_->getWidgetByName("BtnBack");
  if (btn) {
    btn->addTouchEventListener(this, toucheventselector(PlayScene::onBtnBack));
    btn->setPressedActionEnabled(true);
  }

  UIPanel *panel = (UIPanel *)ui_layer_->getWidgetByName("PanelSecond");
  if(panel == NULL) {
    return;
  }
  panel->setVisible(false);
  panel->setTouchEnable(false);

  btn = (UIButton *)ui_layer_->getWidgetByName("BtnStartPlay");
  if (btn) {
    btn->addTouchEventListener(this, toucheventselector(PlayScene::onBtnStartPlay));
    CCScaleTo* scale1 = CCScaleTo::create( 1.0f, 1.2f);
    CCScaleTo* scale2 = CCScaleTo::create( 1.0f, 0.8f);
    CCSequence* scale = CCSequence::createWithTwoActions(scale1, scale2);
    btn->getVirtualRenderer()->runAction(CCRepeatForever::create(scale));
  }
  btn = (UIButton *)ui_layer_->getWidgetByName("BtnShirt");
  if (btn) {
    btn->setTouchEnable(false);
  }
  card_mgr_.SetEnable(false);

  be_back_ = false;
  property_state_ = -1;
}
Exemple #15
0
bool LoginDialog::init()
{
    if (!Dialog::init())
        return false;
    
    initContentWithJsonFile("UI4DialogLogin.ExportJson");
    
    Widget * tmp = _uilayer->getWidgetByName("panel_account");
    _account = CCEditBox::create(CCSize(300, 35), CCScale9Sprite::create("green_edit.png"));
    addChild(_account);
    
    _account->setMaxLength(16);
    _account->setTouchPriority(0);
    _account->setFontColor(ccWHITE);
    _account->setPlaceHolder("联众账号");
    _account->setPlaceholderFontColor(ccWHITE);
    
    _account->setInputMode(kEditBoxInputModeSingleLine);
    _account->setReturnType(kKeyboardReturnTypeDone);
    _account->setInputFlag(kEditBoxInputFlagSensitive);
    
    CCPoint tmpPoint = tmp->convertToWorldSpace(ccp(tmp->boundingBox().size.width/2+47,0));
    _account->setPosition(tmpPoint);
    
    
    tmp = _uilayer->getWidgetByName("panel_password");
    _password = CCEditBox::create(CCSize(300, 35), CCScale9Sprite::create("green_edit.png"));
    
    _password->setMaxLength(16);
    _password->setTouchPriority(0);
    _password->setFontColor(ccWHITE);
    _password->setPlaceHolder("密码");
    _password->setPlaceholderFontColor(ccWHITE);
    
    _password->setReturnType(kKeyboardReturnTypeDone);
    _password->setInputFlag(kEditBoxInputFlagPassword);
    
    tmpPoint = tmp->convertToWorldSpace(ccp(tmp->boundingBox().size.width/2+47, 0));
    _password->setPosition(tmpPoint);
    addChild(_password);
    
    string text = CCUserDefault::sharedUserDefault()->getStringForKey(SAVE_H_ACCOUNT,"fishtest007");
    _account->setText(text.c_str());
    text = CCUserDefault::sharedUserDefault()->getStringForKey(SAVE_H_PASSWORD,"fishtest007");
    _password->setText(text.c_str());
    
    bindTouchEvent("btn_login", this, toucheventselector(LoginDialog::onClickedLogin));
    bindTouchEvent("btn_register", this, toucheventselector(LoginDialog::onClickedRegister));
    
    return true;
}
Exemple #16
0
void MsgContentDialog::setPrize(int num)
{
    string texture = "button_confirm.png";
    SEL_TouchEvent func = toucheventselector(MsgContentDialog::close);
    
    //奖励物品数量大于0 并且 奖励物品的范围,以防奖励不存在的物品
    if (num > 0 && _data->mailType > 0 && _data->mailType < 5)
    {
        int    d;
        string prizeStr;
        switch (_data->mailType) {
            case 1://宠物奖励
            {
                d = _data->itemId - 1;//宠物图片从0开始计数,服务端数据从1开始计数
                prizeStr = "pethead%d.png";
                break;
            }
            case 2://道具奖励
            {
                d = _data->itemId;
                prizeStr = "prop%d.png";
                break;
            }
            default:
            {
                d = _data->mailType;
                prizeStr = "prize%d.png";
                break;
            }
        }
        
        prizeStr = CCString::createWithFormat(prizeStr.c_str(),d)->getCString();
        
        _number->setText(CCString::createWithFormat("%d",num)->getCString());
        _prize->loadTexture(prizeStr.c_str(),UI_TEX_TYPE_PLIST);
        
        if ( !_data->isOK )
        {
            texture = "button_receive.png";
            func = toucheventselector(MsgContentDialog::clickedReceive);
        }
    }
    else
    {
        _wprize->setVisible(false);
    }
    
    _button->loadTextures(texture.c_str(), NULL, NULL , UI_TEX_TYPE_PLIST);//确定
    _button->addTouchEventListener(this, func);

}
void SelectMenuView::noticeShowLock(int beautyIndex, int needHeart)
{
	_panelUnlock->setVisible(true);
	_panelUnlock->setTouchEnabled(true);

	// setting head 
	UIImageView* head = (UIImageView*)_panelUnlock->getChildByName("panelLock_head");
	char tmp[32];
	sprintf(tmp,"head_%d.png",beautyIndex);
	head->loadTexture(tmp,UI_TEX_TYPE_PLIST);

	// setting heart number
	for(int i=0; i<MAX_HEART; i++)
	{
		sprintf(tmp,"panelLock_heart_%d",i+1);
		if(i<needHeart)
		{
			_panelUnlock->getChildByName(tmp)->setVisible(true);
		}
		else
		{
			_panelUnlock->getChildByName(tmp)->setVisible(false);
		}
	}

	// setting beauty name
	UILabelBMFont* labelName = (UILabelBMFont*) _panelUnlock->getChildByName("panelLock_txt_name");
	labelName->setText(BeautyStaticData::getInstance()->getName(beautyIndex));

	// setting unlock price
	UILabelBMFont* labelPrice = (UILabelBMFont*) _panelUnlock->getChildByName("panelLock_txt_price");
	sprintf(tmp,"$%d",BeautyStaticData::getInstance()->getRequiement(beautyIndex+1));
	labelPrice->setText(tmp);

	// animation
	UIWidget* bg = _panelUnlock->getChildByName("panelLock_bg");
	bg->setScale(0.1f);
	bg->runAction(CCScaleTo::create(0.3f,1));

	UIButton* button = (UIButton*)_panelUnlock->getChildByName("panelLock_btn_back");
	button->setTouchEnabled(true);
	button->setPressedActionEnabled(true);
	button->addTouchEventListener(this,toucheventselector(SelectMenuView::onTouchUnlock));
	button = (UIButton*)_panelUnlock->getChildByName("panelLock_btn_unlock");
	button->setTouchEnabled(true);
	button->setPressedActionEnabled(true);
	button->addTouchEventListener(this,toucheventselector(SelectMenuView::onTouchUnlock));

	this->addWidget(_panelUnlock);
}
void MainFrame::Init()
{
	mMainUILayout =  static_cast<ui::Layout*>(GUIReader::shareReader()->widgetFromJsonFile("MainFrame/MainFrame.ExportJson"));
	addWidget(mMainUILayout);

	Button* btn = (Button*)mMainUILayout->getChildByTag(ThreatenButtonTag);  
	btn->addTouchEventListener(this, toucheventselector(MainFrame::ThreatenSkill));

	btn = (Button*)mMainUILayout->getChildByTag(AddSkillTag);
	btn->addTouchEventListener(this, toucheventselector(MainFrame::AddSkillUI));

	mLevelText = (LabelAtlas*)mMainUILayout->getChildByTag(LevelTag); 
	mExperienceBar = (LoadingBar*)mMainUILayout->getChildByTag(ExperienceTag);
}
bool MainLayer::init()
{
	if (!CCLayer::init())
		return false;

	enableKeypad();

	m_uiLayer = UILayer::create();
	addChild(m_uiLayer);

	m_layoutWidget = dynamic_cast<UILayout *>(GUIReader::shareReader()->widgetFromJsonFile("StartLayer.json"));
	if (!m_layoutWidget)
	{
		return false;
	}
	m_uiLayer->addWidget(m_layoutWidget);

	m_petUIImage = dynamic_cast<UIImageView *>(m_uiLayer->getWidgetByName("petImage"));
	m_petUIImage->addTouchEventListener(this, toucheventselector(MainLayer::pressPetImageCallback));
	m_petUIImage->setTouchEnabled(true);

	m_centerPos = m_petUIImage->getPosition();

	m_startUIImage = dynamic_cast<UIImageView *>(m_uiLayer->getWidgetByName("startbutton"));
	m_startUIImage->addTouchEventListener(this, toucheventselector(MainLayer::pressStartButtonCallback));
	m_startUIImage->setTouchEnabled(true);

	m_changeLabel = dynamic_cast<UILabelBMFont *>(m_uiLayer->getWidgetByName("changeLabel"));
	m_changeLabel->addTouchEventListener(this, toucheventselector(MainLayer::pressChangeRoleCallback));
	m_changeLabel->setTouchEnabled(true);

	m_priceTipsLabel = dynamic_cast<UILabel *>(m_uiLayer->getWidgetByName("feeLabel"));
	m_cherryLabel = dynamic_cast<UILabelBMFont *>(m_uiLayer->getWidgetByName("cherryLabel"));
	m_bestScoreLabel = dynamic_cast<UILabelBMFont *>(m_uiLayer->getWidgetByName("bestScoreLabel"));
	m_gameTimesScoreLabel = dynamic_cast<UILabelBMFont *>(m_uiLayer->getWidgetByName("gametimesScoreLabel"));

	m_petType = (PetType)Config::instance()->petType();
	setPriceTipText(m_petType);
	updatePetImage(m_petType);

	int cherryNum = Config::instance()->cherryNum();
	int gameTimes = Config::instance()->gameTimes();
	int highScore = Config::instance()->highScore();

	updateMainText(cherryNum, gameTimes, highScore);

	WebSocketManager::instance();
	
	return true;
}
Exemple #20
0
void MainScene::updateList(CCObject *sender)
{
    if (xCurAtk == NULL || m_state != CS_MAIN_PLIST) {
        return;
    }
    
    listView->removeAllItems();
    
    for (int i = 0; i < xCurAtk->getPartsCount(); ++i)
    {
        listView->pushBackDefaultItem();
    }
    
    CCArray* items = listView->getItems();
    for (int i = 0; i < items->count(); i++) {
        Layout * bg = (Layout*)items->objectAtIndex(i);
        bg->addTouchEventListener(this, toucheventselector(MainScene::touchEvent));
        bg->setTag(LIST_BG + i);
        Label *label = (Label*)UIHelper::seekWidgetByTag(bg, 22);
        label->setText(xCurAtk->getPartNameByIndex(i));
    }
    
    makeAFocusOfList();
    updateCheckBox();
}
Exemple #21
0
bool SettingDialog::init()
{
    if ( !Dialog::initContentWithJsonFile("UI4DialogSet.ExportJson") )
        return false;
    
    button_music = dynamic_cast<Button*>(getWidgetByName("Button_music"));
    button_effect = dynamic_cast<Button*>(getWidgetByName("Button_effect"));
    
    progress_music =  dynamic_cast<LoadingBar*>(getWidgetByName("ProgressBar_music"));
    progress_effect = dynamic_cast<LoadingBar*>(getWidgetByName("ProgressBar_effect"));
    
    bindTouchEvent("Button_switchAccount", this, toucheventselector(SettingDialog::clickedSwitchAccount));
    
    button_music->addTouchEventListener(this, toucheventselector(SettingDialog::regulateSound));
    return true;
}
bool UILoadingBarTest_Editor::init()
{
    if (UIScene_Editor::init())
    {
        scheduleUpdate();
        
        _layout = static_cast<Layout*>(GUIReader::shareReader()->widgetFromJsonFile("cocosgui/UIEditorTest/UILoadingBar_Editor/ui_loadingbar_editor_1.json"));
        _touchGroup->addWidget(_layout);
        CCSize screenSize = CCDirector::sharedDirector()->getWinSize();
        CCSize rootSize = _layout->getSize();
        _touchGroup->setPosition(CCPoint((screenSize.width - rootSize.width) / 2,
                                        (screenSize.height - rootSize.height) / 2));
        
        Layout* root = static_cast<Layout*>(_touchGroup->getWidgetByName("root_Panel"));
        
        ui::Label* back_label = static_cast<ui::Label*>(UIHelper::seekWidgetByName(root, "back"));
        back_label->addTouchEventListener(this, toucheventselector(UIScene_Editor::toGUIEditorTestScene));
        
        _sceneTitle = static_cast<ui::Label*>(UIHelper::seekWidgetByName(root, "UItest"));
        
        LoadingBar* loadingBar_left_to_right = dynamic_cast<LoadingBar*>(UIHelper::seekWidgetByName(root, "LoadingBar_856"));
        loadingBar_left_to_right->setPercent(0);
        
        LoadingBar* loadingBar_right_to_left = dynamic_cast<LoadingBar*>(UIHelper::seekWidgetByName(root, "LoadingBar_857"));
        loadingBar_right_to_left->setPercent(0);
        
        return true;
    }
    
    return false;
}
Exemple #23
0
void PlayScene::onBtnClothes(CCObject *target, TouchEventType e) {
  UIButton* btn = (UIButton *)ui_layer_->getWidgetByName(btn_name[sub_stage_id_]);
  if (btn) {
    if(e == TOUCH_EVENT_BEGAN) {
      btn_start_pos_ = btn->getPosition();
    } else if(e == TOUCH_EVENT_ENDED) {
      CCPoint pos = btn->getPosition();
      if(btn_start_pos_.fuzzyEquals(pos, 100.0f)) {
        btn->setPosition(btn_start_pos_);
      } else {
        if(!all_finish_) {
          btn->setEnabled(false);
          btn = (UIButton *)ui_layer_->getWidgetByName("BtnStartPlay");
          btn->setEnabled(true); 
        } else {
          btn->setEnabled(false);
          User::CurrentUser()->set_stageid(stageid_ + 1);
          User::CurrentUser()->Flush();
          PopWin::Instance().ShowPopScene(this, true, toucheventselector(PlayScene::onPopBack));
        }
      }
    }
  }
  CCLOG("%s\n", __FUNCTION__);
}
Exemple #24
0
bool IntroScene::init()
{
	//super init
	if (!Layer::init())
	{
		return false;
	}
	Size visibleSize = Director::getInstance()->getVisibleSize();
	Point origin = Director::getInstance()->getVisibleOrigin();

	/////////////////////////////////////////////////////
	AudioEngine::getInstance()->createLoop("bgm/intro.ogg");
	auto sceneNode = cocostudio::SceneReader::getInstance()->createNodeWithSceneFile("introScene.json");
	addChild(sceneNode);
	auto UINode = sceneNode->getChildByTag(10003);
	auto UIComponent = (cocostudio::ComRender*) UINode->getComponent("GUIComponent");
	auto UIlayer = UIComponent->getNode();
	auto background = dynamic_cast<ImageView*>(UIlayer->getChildByTag(INTROSCENE_BG));
	auto buttonStart = dynamic_cast<Button*>(UIlayer->getChildByTag(INTROSCENE_START));
	auto title = dynamic_cast<ImageView*>(UIlayer->getChildByTag(INTROSCENE_ECHO));
	title->runAction(RepeatForever::create(Sequence::create(FadeIn::create(3), FadeOut::create(3), NULL)));
	buttonStart->runAction(RepeatForever::create(Sequence::create(FadeIn::create(1), DelayTime::create(1), FadeOut::create(1), NULL)));
	buttonStart->addTouchEventListener(this, toucheventselector(IntroScene::touchEvent));

	auto logo = Sprite::create("introSceneUI/logo.png");
	logo->setPosition(Point(visibleSize.width / 2 + origin.x, visibleSize.height / 2 + origin.y));
	logo->setLocalZOrder(1);
	sceneNode->addChild(logo);
	logo->runAction(Sequence::create(DelayTime::create(1), CallFunc::create(CC_CALLBACK_0(IntroScene::playIntro, this)), FadeOut::create(2), NULL));//logoÇл»ÌØЧ
	return true;
}
Exemple #25
0
void CGridIcon::updateByContent()
{
    if(m_GridsType == emGrids_BagBook)
    {
        ShowQuality();
        ShowIcon();
        ShowMask();
        ShowNum();
        ShowPrecent();
        ShowPrecentBar();
        ShowLevel();
    }
    else
    {
        ShowQuality();
        ShowIcon();
        ShowMask();
        ShowNum();
        ShowCd();
    }
    setTouchEnabled(true);
    if (m_bCanMove&&m_pItem)
    {
        CDragCtrol* pDrag = CDragCtrol::create(this,m_pItem->getId(),DragSlotType_Item,this,toucheventselector(CGridIcon::clickGridIcon),NULL);
        addChild(pDrag);
    }
    else
    {
        addTouchEventListener(this,toucheventselector(CGridIcon::clickGridIcon));
    }
}
void CocosGUIExamplesPageScene::onEnter()
{
    CCScene::onEnter();
    
    m_pUILayer = TouchGroup::create();
    m_pUILayer->scheduleUpdate();
    addChild(m_pUILayer);
    
    PageInit();
    
    CCSize winSize = CCDirector::sharedDirector()->getWinSize();
    
    gui::Label* label = gui::Label::create();
    label->setText("Move by horizontal direction");
    const char* font =
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
    // custom ttf files are defined in Test-info.plist
    "Marker Felt";
#else
    "fonts/Marker Felt.ttf";
#endif
    label->setFontName(font);
    label->setFontSize(32);
    label->setAnchorPoint(ccp(0.5f, -1));
    label->setPosition(ccp(winSize.width / 2.0f, winSize.height / 2.0f + label->getSize().height * 1.5));
    m_pUILayer->addWidget(label);
    
    // exit button
    Button* exit_button = Button::create();
    exit_button->setTouchEnabled(true);
    exit_button->loadTextures("CloseNormal.png", "CloseSelected.png", "");
    exit_button->setPosition(ccp(m_pUILayer->getContentSize().width - exit_button->getSize().width, exit_button->getSize().height));
    exit_button->addTouchEventListener(this, toucheventselector(CocosGUIExamplesPageScene::menuCloseCallback));
    m_pUILayer->addWidget(exit_button);
}
Exemple #27
0
void PlayScene::SetResultPanelState(int state) {
  UIPanel *panel = (UIPanel *)ui_layer_->getWidgetByName("PanelSecond");
  if(panel == NULL) {
    return;
  }

  switch(state) {
  case RESULT_PANEL_NORMAL:
    panel->setVisible(false);
    panel->setTouchEnable(false);
    break;
  case RESULT_PANEL_WIN:
    {
      panel->setVisible(true);
      panel->setTouchEnable(true);
      SetIamgeView("WinOrLose", true, "play_banner_win.png");
      char name[32] = {};
      sprintf(name,"girl%d_face_0004.png",stageid_);
      SetIamgeView("WinOrLoseGirl", true, name);
      ShowTips(true, TIPS_TYPE_RESULT_END);
      panel->addTouchEventListener(this, toucheventselector(PlayScene::onPanelSecond));
      break;
    }
  case RESULT_PANEL_LOSE:
    {
      panel->setVisible(true);
      panel->setTouchEnable(true);
      SetIamgeView("WinOrLose", true, "play_banner_lose.png");
      char name[32] = {};
      sprintf(name,"girl%d_face_0005.png",stageid_);
      SetIamgeView("WinOrLoseGirl", true, name);
      ShowTips(true, TIPS_TYPE_RESULT_END);
      panel->addTouchEventListener(this, toucheventselector(PlayScene::onPanelSecond));
      break;
    }
  case RESULT_PANEL_START:
    {
      panel->setVisible(true);
      panel->setTouchEnable(false);
      SetIamgeView("WinOrLose", false);
      SetIamgeView("WinOrLoseGirl", false);
      ShowTips(true, TIPS_TYPE_ACTION_BEGIN);
    }
  default:
    break;
  }
}
//----------------------------------------------------------------------------------------------------
void GROperationScene::initCallback(void)
{
    if (!this->operatorUI) return;
    
    Button* playButton = dynamic_cast<Button*>(Helper::seekWidgetByName(this->operatorUI, "playButton"));
    if (playButton) playButton->addTouchEventListener(this, toucheventselector(GROperationScene::playButtonCallback));
    
    Button* actorSelectButton = dynamic_cast<Button*>(Helper::seekWidgetByName(this->operatorUI, "actorSelectButton"));
    if (actorSelectButton) actorSelectButton->addTouchEventListener(this, toucheventselector(GROperationScene::actorSelectButtonCallback));
    
    Button* settingButton = dynamic_cast<Button*>(Helper::seekWidgetByName(this->operatorUI, "settingButton"));
    if (settingButton) settingButton->addTouchEventListener(this, toucheventselector(GROperationScene::settingButtonCallback));
    
    auto listener = EventListenerKeyboard::create();
    listener->onKeyReleased = CC_CALLBACK_2(GROperationScene::onKeyReleased, this);
    Director::getInstance()->getEventDispatcher()->addEventListenerWithSceneGraphPriority(listener, this);
}
void CocosGUIExamplesMapScene::MapAlertInit()
{
    // map alert from json
    Layout* alert_panel = static_cast<Layout*>(Helper::seekWidgetByName(_root, "alert_Panel"));
    
    Button* close_button = static_cast<Button*>(alert_panel->getChildByName("close_Button"));
    close_button->addTouchEventListener(this, toucheventselector(CocosGUIExamplesMapScene::MapAlertClose));
}
Exemple #30
0
bool UIScene::init()
{
    if (CCLayer::init())
    {
        m_pUiLayer = UILayer::create();
        addChild(m_pUiLayer);
        
        m_pWidget = dynamic_cast<UILayout*>(GUIReader::shareReader()->widgetFromJsonFile("cocosgui/UITest/UITest.json"));
        m_pUiLayer->addWidget(m_pWidget);
        CCSize screenSize = CCDirector::sharedDirector()->getWinSize();
        CCSize rootSize = m_pWidget->getSize();
        m_pUiLayer->setPosition(CCPoint((screenSize.width - rootSize.width) / 2,
                                    (screenSize.height - rootSize.height) / 2));
        m_pSceneTitle = dynamic_cast<UILabel*>(m_pUiLayer->getWidgetByName("UItest"));
        
        UILabel* back_label = dynamic_cast<UILabel*>(m_pUiLayer->getWidgetByName("back"));
        back_label->addTouchEventListener(this, toucheventselector(UIScene::toCocosGUITestScene));
        
        UIButton* left_button = dynamic_cast<UIButton*>(m_pUiLayer->getWidgetByName("left_Button"));
        left_button->addTouchEventListener(this, toucheventselector(UIScene::previousCallback));
        
        UIButton* middle_button = dynamic_cast<UIButton*>(m_pUiLayer->getWidgetByName("middle_Button"));
        middle_button->addTouchEventListener(this, toucheventselector(UIScene::restartCallback));
        
        UIButton* right_button = dynamic_cast<UIButton*>(m_pUiLayer->getWidgetByName("right_Button"));
        right_button->addTouchEventListener(this, toucheventselector(UIScene::nextCallback));
        
        /*
        for (int i = 0; i < 4; ++i)
        {
            CCNode* node = CCNode::create();
            node->setPosition(VisibleRect::center());
            CCNode* sprite = CCSprite::create();
            dynamic_cast<CCSprite*>(sprite)->initWithFile("Hello.png");
//            dynamic_cast<CCSprite*>(sprite)->initWithFile("cocosgui/UITest/background.png");
//            sprite->setPosition(VisibleRect::center());
            node->addChild(sprite);
            m_pUiLayer->addChild(node);
        }
         */
        
        return true;
    }
    return false;
}