Exemple #1
0
void Bag::initEquips()
{
	UIPanel* equipPanel = dynamic_cast<UIPanel*>(uiLayer->getWidgetByName("equippanel"));
	CCArray* equips = equipPanel->getChildren();
	CCObject* object = NULL;

	int bagGridCount = 1;

	int equipType = EQUIP_TYPE_HELMET;		//the first type of equip

	CCARRAY_FOREACH(equips,object)
	{
		UIPanel* equipChildPanel = (UIPanel*)object;
		CCArray* equips = equipChildPanel->getChildren();

		int equipStartNum = 1;

		CCARRAY_FOREACH_REVERSE(equips, object)
		{
			UIWidget* equip = dynamic_cast<UIWidget*>(object);
			equip->addTouchEventListener(this,toucheventselector(Bag::touchEvent));
			initEquipID(equip,equipType,equipStartNum);
			
			UIWidget* bagGrid = getBagGrid(bagGridCount++);
			changeParent(bagGrid,equip);

			equipStartNum++;
		}
Exemple #2
0
bool UILaoHuJi::init()
{
	m_fileName = "LaoHuJi.ExportJson";
	topLight = 0;
	bottomLight = 0;
	topDtime = 0;
	buttomDtime = 0;
	bLinkTime = 0;
	runDtime = 0;

	state = LaoHuJi_Hiddent;

	if( UIBase::init() )
	{
		// parse
		UIImageView* bgImage = static_cast<UIImageView*>(m_pWidget->getChildByName("bg"));
		m_pLeftListView = static_cast<ListView*>(bgImage->getChildByName("leftListView"));
		m_pRightListView = static_cast<ListView*>(bgImage->getChildByName("rightListView"));

		m_pCloseBtn = static_cast<UIButton*>(m_pWidget->getChildByName("closeBtn"));
		m_pDrawBtn =  static_cast<UIButton*>(m_pWidget->getChildByName("drawBtn"));
		m_pFreeImg =  static_cast<UIImageView*>(m_pDrawBtn->getChildByName("freeImg"));

		UIPanel* buttomPanel = static_cast<UIPanel*>(m_pWidget->getChildByName("buttomPanel"));
		
		CCString* str;
		for( int i = 0 ; i < 24 ; i++ )
		{
			str = CCString::createWithFormat("normalLight_%d",(i+1));
			m_pNormalLight[i] = static_cast<UIImageView*>(buttomPanel->getChildByName(str->getCString()));
			m_pOnLight[i] = static_cast<UIImageView*>(m_pNormalLight[i] ->getChildByName("onLight"));

			m_pOnLight[i]->setVisible( false );
		}

		UIPanel* topPanel = static_cast<UIPanel*>(m_pWidget->getChildByName("topPanel"));
		for( int i = 0 ; i < 5 ; i++ )
		{
			str = CCString::createWithFormat("noramStar_%d",(i+1));
			m_pNormalStar[i] = static_cast<UIImageView*>(topPanel->getChildByName(str->getCString()));
			m_pOnStar[i] = static_cast<UIImageView*>(m_pNormalStar[i] ->getChildByName("onStar"));
			m_pOnStarBg[i] = static_cast<UIImageView*>(m_pNormalStar[i] ->getChildByName("onStarBg"));
		
			m_pOnStarBg[i]->setVisible( false );
			m_pOnStar[i]->setVisible( false );
		}

		// register event
		m_pCloseBtn->addTouchEventListener( this , toucheventselector( UILaoHuJi::closeLaoHuJi));
		m_pDrawBtn->addTouchEventListener( this , toucheventselector( UILaoHuJi::starLaoHuJi));

		m_pUILayer->retain();
		m_pWidget->retain();
	}

	this->setHiddent( true );
	return true;
}
Exemple #3
0
	void callback(UIBase *base)
	{
		if (window)
		{
			UIPanel * target = window->showPanel(gloabFileName.c_str());
			if (target)
			{
				target->makeXmlFile(gloabFileName.c_str());
			}
		}
	}
Exemple #4
0
/**
 * 设置父类的bind
 */
int UILib::parent_p_bind(UIStub* stub,script::tixmlCodeNode * node)
{
	if (stub && stub->base)
	{
		UIPanel *panel = stub->base->getPanel();
		if (panel)
		{
			panel->bindBtnClick(node->getAttr("btnname"),UICALLBACK(node->getAttr("event")));
		}
	}
	return 1;
}
Exemple #5
0
/**
 * 设置父类
 */
int UILib::parent_p_label_set_value(UIStub* stub,script::tixmlCodeNode * node)
{
	if (stub && stub->base)
	{
		UIPanel *panel = stub->base->getPanel();
		if (panel)
		{
			panel->setUILabelvalue(node->getAttr("labelname"),node->getAttr("value"));
		}
	}
	return 1;
}
Exemple #6
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;
}
bool GameLayer_GoldMarket::init()
{
    if (!CCLayer::init()) {
        return false;
    }
    //系统设置界面.
    goldMarket = UILayer::create();
    auto layout = dynamic_cast<Layout*>(GUIReader::shareReader()->widgetFromJsonFile("./CocoStudioResources/GoldMarket.json"));
    goldMarket->addWidget(layout);
    //    sysSet->setVisible(true);
    this->addChild(goldMarket, 0, 101);
    
    UIPanel* panel = dynamic_cast<UIPanel*>(goldMarket->getWidgetByName("Panel"));
    panel->setBackGroundColor(ccBLACK);
    panel->setBackGroundColorOpacity(150);
    //关闭按钮
    UIButton* closeBtn = dynamic_cast<UIButton*>(goldMarket->getWidgetByName("CloseBtn"));
    closeBtn->setTouchEnable(true);
    closeBtn->addReleaseEvent(this, coco_releaseselector(GameLayer_GoldMarket::closeBtnCallback));
    closeBtn->setPressedActionEnabled(true);
    
    //购买按钮.
    UIButton* buyBtn_0 = dynamic_cast<UIButton*>(goldMarket->getWidgetByName("BuyBtn_0"));
    buyBtn_0->setTag(Buy_0);
    buyBtn_0->setPressedActionEnabled(true);
    buyBtn_0->addReleaseEvent(this, coco_releaseselector(GameLayer_GoldMarket::buyBtnCallback));
    UIButton* buyBtn_1 = dynamic_cast<UIButton*>(goldMarket->getWidgetByName("BuyBtn_1"));
    buyBtn_1->setTag(Buy_1);
    buyBtn_1->setPressedActionEnabled(true);
    buyBtn_1->addReleaseEvent(this, coco_releaseselector(GameLayer_GoldMarket::buyBtnCallback));
    UIButton* buyBtn_2 = dynamic_cast<UIButton*>(goldMarket->getWidgetByName("BuyBtn_2"));
    buyBtn_2->setTag(Buy_2);
    buyBtn_2->setPressedActionEnabled(true);
    buyBtn_2->addReleaseEvent(this, coco_releaseselector(GameLayer_GoldMarket::buyBtnCallback));
    UIButton* buyBtn_3 = dynamic_cast<UIButton*>(goldMarket->getWidgetByName("BuyBtn_3"));
    buyBtn_3->setTag(Buy_3);
    buyBtn_3->setPressedActionEnabled(true);
    buyBtn_3->addReleaseEvent(this, coco_releaseselector(GameLayer_GoldMarket::buyBtnCallback));
    //UIButton* buyBtn_4 = dynamic_cast<UIButton*>(goldMarket->getWidgetByName("BuyBtn_4"));
    //buyBtn_4->setTag(Buy_4);
    //buyBtn_4->setPressedActionEnabled(true);
    //buyBtn_4->addReleaseEvent(this, coco_releaseselector(GameLayer_GoldMarket::buyBtnCallback));
    
    
    this->setValue();

    //添加兑换按钮
    this->setVisible(true);
    return true;
}
void GameLayer_Menu::setNoLogin(bool visiable)
{
    UIPanel* dayLoginPanel = dynamic_cast<UIPanel*>(gameMenu->getWidgetByName("MenuBtn"));
    dayLoginPanel->setVisible(visiable);
    UIButton* taskBtn = dynamic_cast<UIButton*>(gameMenu->getWidgetByName("SysInfoBtn"));
    taskBtn->setTouchEnable(visiable);
    UIButton* emailBtn = dynamic_cast<UIButton*>(gameMenu->getWidgetByName("EmailBtn"));
    emailBtn->setTouchEnable(visiable);
    UIButton* addFriendBtn = dynamic_cast<UIButton*>(gameMenu->getWidgetByName("AddFriendBtn"));
    addFriendBtn->setTouchEnable(visiable);
    UIButton* rankBtn = dynamic_cast<UIButton*>(gameMenu->getWidgetByName("RankBtn"));
    rankBtn->setVisible(visiable);
    rankBtn->setTouchEnable(visiable);
}
Exemple #9
0
int UILib::hideparentpanel(UIStub* stub,script::tixmlCodeNode * node)
{
	if (stub && stub->base)
	{
		UIPanel *panel = stub->base->getPanel();
		if (panel)
		{
			if (panel)
			{
				panel->hide();
			}
		}
	}
	return 1;
}
Exemple #10
0
/**
* 隐藏Panel
*/
int UILib::hidepanel(UIStub* stub,script::tixmlCodeNode * node)
{
	if (stub && stub->base)
	{
		UIWindow *window = stub->base->getDepthWindow();
		if (window)
		{
			UIPanel *target = window->getPanel(node->getAttr("name"));
			if (target)
			{
				target->hide();
			}
		}
	}
	return 1;
}
Exemple #11
0
	virtual void callback(UIBase *base)
	{
		if (dialog && window)
		{
			// 创建图片
			UIPanel *panel = window->getNowTouchPanel();
			if (panel)
			{
				UIImage *image = (UIImage*) panel->createImage(ccp(0,300),CCSizeMake(0,0),"defaultimg.png",panel);
				if (image)
				{
					image->setEditable(true);
					image->bind(UIBase::EVENT_EDIT_DOWN,new stShowProp());
				}
			}
		}
	}
Exemple #12
0
	virtual void callback(UIBase *base)
	{
		if (dialog && window)
		{
			// 创建图片
			UIPanel *panel = window->getNowTouchPanel();
			if (panel)
			{
				UILabel * label = (UILabel*)panel->createLabel(ccp(0,0),CCSizeMake(0,0),"default",32,panel);
				if (label)
				{
					label->setEditable(true);
					label->bind(UIBase::EVENT_EDIT_DOWN,new stShowProp());
				}
			}
		}
	}
Exemple #13
0
	virtual void callback(UIBase *base)
	{
		if (dialog && window)
		{
			// 创建图片
			UIPanel *panel = window->getNowTouchPanel();
			if (panel)
			{
				UIEditField *editField = (UIEditField*) panel->createTextField(ccp(0,0),CCSizeMake(100,32),"hello,world",panel);
				if (editField)
				{
					editField->setEditable(true);
					editField->bind(UIBase::EVENT_EDIT_DOWN,new stShowProp());
				}
			}
		}
	}
Exemple #14
0
	virtual void callback(UIBase *base)
	{
		if (dialog && window)
		{
			UIPanel *panel = window->getNowTouchPanel();
			if (panel)
			{
				UIButton *btn = (UIButton*)panel->createButton(ccp(0,300),CCSizeMake(64,64),
					"btn_common_down.png","btn_common_up.png",panel);
				if (btn)
				{
					btn->setEditable(true);
					btn->bind(UIBase::EVENT_EDIT_DOWN,new stEditDown(dialog,window));
				}
			}
		}
	}
Exemple #15
0
/**
 * 绑定自身panel 的处理逻辑 C++ 写的逻辑
 */
int UILib::panelbind(UIStub* stub,script::tixmlCodeNode * node)
{
	if (stub && stub->base)
	{
		UIPanel *panel = stub->base->getPanel();
		if (panel)
		{
			UIWindow *window = panel->getWindow();
			if (window)
			{
				UIPanel *target = window->getPanel(node->getAttr("name"));
				if (target)
					target->bindBtnClick(node->getAttr("btnname"),UICALLBACK(node->getAttr("event")));
			}	
		}
	}
	return 1;
}
Exemple #16
0
	void callback(UIBase *base)
	{
		if (window)
		{
			UIPanel *panel = base->getPanel();
			if (panel)
			{
				// 获取各个字段的值
				std::string fileName = panel->getUILablevalue("filename");
				UIPanel * target = window->showPanel(fileName.c_str());
				if (target)
				{
					target->setEditable(true);
				}
				gloabFileName = fileName;
				panel->hide();
			}
		}
	}
Exemple #17
0
/**
* 展示panel 
*/
int UILib::showpanel(UIStub* stub,script::tixmlCodeNode * node)
{
	if (stub && stub->base)
	{
		UIWindow *window = stub->base->getDepthWindow();
		if (window)
		{
			UIPanel *panel = window->showPanel(node->getAttr("name"));
			std::string tag = node->getAttr("model");
			if (tag == "true" && panel)
			{
				window->pushModel(panel);
			}
			if (panel)
			panel->setVisible(true);
		}
	}
	return 1;
}
bool GestureScene::init() {
    if ( !CCLayer::init() ) 
        return false;
    CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
    CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();
	this->setTouchEnabled(true);

	UILayer* uiLayer = UILayer::create();  
    uiLayer->addWidget(GUIReader::shareReader()->widgetFromJsonFile("UI/GestureUI/GestureUI.json"));  

	UIPanel* rootPanel = (UIPanel*)uiLayer->getWidgetByName("rootPanel");
	xLabel = (UILabel*) rootPanel->getChildByName("touchXLabel");
	yLabel = (UILabel*) rootPanel->getChildByName("touchYLabel");
	resultLabel = (UILabel*) rootPanel->getChildByName("gestureNameLabel");

    this->addChild(uiLayer, 2);

    return true;
}
Exemple #19
0
/**
 * 设置panel 上UILabel 的值
 */
int UILib::panel_label_set_value(UIStub* stub,script::tixmlCodeNode * node)
{
	if (stub && stub->base)
	{
		UIPanel *panel = stub->base->getPanel();
		if (panel)
		{
			UIWindow *window = panel->getWindow();
			if (window)
			{
				UIPanel *target = window->getPanel(node->getAttr("name"));
				if (target)
				{
					target->setUILabelvalue(node->getAttr("labelname"),node->getAttr("value"));
				}
			}	
		}
	}
	return 1;
}
Exemple #20
0
void Application::InitGUI()
{
    m_UIManager = new UIManager(m_Renderer);
    m_Renderer->SetUIManager(m_UIManager);
    m_UIManager->Initialize();
    m_UIManager->SetZClipPlanes(0.0f,200.0f);

    Byte* fDat = Load("Common/font24px/Font.fnt");
    Font* Fnt = new Font();
    Fnt->Load(fDat);
    Fnt->SetFontImage(LoadTexture("Common/font24px/Font.png"));
    m_UIManager->SetFont(Fnt);

    UIPanel* p = new UIPanel(Vec2(20,20));
    p->SetBackgroundColor(Vec4(1,1,1,1));
    p->SetBackgroundImage(LoadTexture("Common/Cursor.png"));
    m_Cursor = p;
    m_UIManager->AddElement(m_Cursor);

    glfwSetInputMode          (m_Window->GetWindow(),GLFW_CURSOR,GLFW_CURSOR_DISABLED);
    glfwSetMouseButtonCallback(m_Window->GetWindow(),OnClick     );
    glfwSetCursorPosCallback  (m_Window->GetWindow(),OnCursorMove);
    glfwSetKeyCallback        (m_Window->GetWindow(),OnKey       );
}
bool UIPanelTest_Color::init()
{
    if (UIScene::init())
    {
        CCSize screenSize = CCDirector::sharedDirector()->getWinSize();        
        
        // Add the alert
        UILabel *alert = UILabel::create();
        alert->setText("Panel color render");
        alert->setFontName("Marker Felt");
        alert->setFontSize(30);
        alert->setColor(ccc3(159, 168, 176));
        alert->setPosition(ccp(screenSize.width / 2.0f, screenSize.height / 2.0f - alert->getRect().size.height * 2.925));
        m_pUiLayer->addWidget(alert);
        
        UIPanel *background = dynamic_cast<UIPanel*>(m_pUiLayer->getWidgetByName("background_Panel"));
        
        // Create the panel with color render
        UIPanel* panel = UIPanel::create();
        panel->setBackGroundColorType(PANEL_COLOR_SOLID);
        panel->setBackGroundColor(ccc3(128, 128, 128));
        panel->setClippingEnable(true);
        panel->setSize(CCSizeMake(280, 150));
        CCSize backgroundSize = background->getContentSize();
        panel->setPosition(ccp((screenSize.width - backgroundSize.width) / 2 +
                               (backgroundSize.width - panel->getRect().size.width) / 2,
                               (screenSize.height - backgroundSize.height) / 2 +
                               (backgroundSize.height - panel->getRect().size.height) / 2));
        m_pUiLayer->addWidget(panel);
        
        UIButton* button = UIButton::create();
        button->setTouchEnable(true);
        button->setTextures("cocosgui/animationbuttonnormal.png", "cocosgui/animationbuttonpressed.png", "");
        button->setPosition(ccp(button->getRect().size.width / 2, panel->getRect().size.height - button->getRect().size.height / 2));
        panel->addChild(button);
        
        UITextButton* textButton = UITextButton::create();
        textButton->setTouchEnable(true);
        textButton->setTextures("cocosgui/backtotopnormal.png", "cocosgui/backtotoppressed.png", "");
        textButton->setText("Text Button");
        textButton->setPosition(ccp(panel->getRect().size.width / 2, panel->getRect().size.height / 2));
        panel->addChild(textButton);
        
        UIZoomButton* zoomButton = UIZoomButton::create();
        zoomButton->setTouchEnable(true);
        zoomButton->setTextures("cocosgui/button.png", "cocosgui/buttonHighlighted.png", "cocosgui/button.png");
        zoomButton->setTitle("ControlButton", "ControlButton", "ControlButton");
        zoomButton->setNormalFontSize(16);
        zoomButton->setNormalFontName("Marker Felt");
        zoomButton->setPressedFontSize(16);
        zoomButton->setPressedFontName("Marker Felt");
        zoomButton->setDisabledFontSize(16);
        zoomButton->setDisabledFontName("Marker Felt");
        zoomButton->setPreferredSize(CCSizeMake(100, zoomButton->getContentSize().height * 2.0f));
        zoomButton->setPosition(ccp(panel->getRect().size.width - zoomButton->getRect().size.width / 2,
                                       zoomButton->getRect().size.height / 2));
        panel->addChild(zoomButton);
        
        return true;
    }
    return false;
}
Exemple #22
0
bool UIStrengthen::init()
{
	if (!CCLayer::init())
	{
		return false;
	}

	uiLayer = UILayer::create();

	UILayout* strengthenRoot = dynamic_cast<UILayout*>(GUIReader::shareReader()->widgetFromJsonFile("ui/UIStrengthen.ExportJson"));
	uiLayer->addWidget(strengthenRoot);

	UIButton* closeButton = dynamic_cast<UIButton*>(uiLayer->getWidgetByName("CloseButton"));
	closeButton->addTouchEventListener(this, toucheventselector(UIStrengthen::closeButtonClicked));

	UIButton* strengthenButton = dynamic_cast<UIButton*>(uiLayer->getWidgetByName("StrengthenButton"));
	strengthenButton->addTouchEventListener(this, toucheventselector(UIStrengthen::strengthenButtonClicked));

	UIButton* pageLeftButton = dynamic_cast<UIButton*>(uiLayer->getWidgetByName("PageLeftButton"));
	pageLeftButton->addTouchEventListener(this, toucheventselector(UIStrengthen::pageLeftButtonClicked));

	UIButton* pageRightButton = dynamic_cast<UIButton*>(uiLayer->getWidgetByName("PageRightButton"));
	pageRightButton->addTouchEventListener(this, toucheventselector(UIStrengthen::pageRightButtonClicked));

	for (int i = 0; i < 4; i++)
	{
		const char* s = CCString::createWithFormat("EquipmentButton_%d", i+1)->getCString();
		UIButton* equipmentButton = dynamic_cast<UIButton*>(uiLayer->getWidgetByName(s));
		equipmentButton->addTouchEventListener(this, toucheventselector(UIStrengthen::equipmentButtonClicked));
	}

	for (int i = 0; i < 2; i++)
	{
		const char* s = CCString::createWithFormat("GemButton_%d", i+1)->getCString();
		UIButton* gemButton = dynamic_cast<UIButton*>(uiLayer->getWidgetByName(s));
		gemButton->addTouchEventListener(this, toucheventselector(UIStrengthen::gemButtonClicked));
	}

	for (int i = 0; i < 4; i++)
	{
		const char* s = CCString::createWithFormat("EquipmentImageView_%d", i+1)->getCString();
		equipmentImageView[i] = dynamic_cast<UIImageView*>(uiLayer->getWidgetByName(s));
	}

	for (int i = 0; i < 3; i++)
	{
		const char* s = CCString::createWithFormat("GemImageView_%d", i+1)->getCString();
		gemImageView[i] = dynamic_cast<UIImageView*>(uiLayer->getWidgetByName(s));
	}

	for (int i = 0; i < 2; i++)
	{
		const char* s = CCString::createWithFormat("GemFrontImageView_%d", i+1)->getCString();
		gemFrontImageView[i] = dynamic_cast<UIImageView*>(uiLayer->getWidgetByName(s));
	}

	strengthenfeatureImageView = dynamic_cast<UIImageView*>(uiLayer->getWidgetByName("FeatureImageView"));

	strengthenTestButton = dynamic_cast<UIButton*>(uiLayer->getWidgetByName("StrengthenTestButton"));

	selectFrameImageView = dynamic_cast<UIImageView*>(uiLayer->getWidgetByName("SelectFrameImageView"));

	UIPanel* tableViewPanel = dynamic_cast<UIPanel*>(uiLayer->getWidgetByName("TableViewPanel"));

	CCTableView* strengthenTableView = CCTableView::create(this, CCSizeMake(strengthenTestButton->getContentSize().width, tableViewPanel->getContentSize().height));
	strengthenTableView->setDirection(kCCScrollViewDirectionVertical);
	strengthenTableView->setVerticalFillOrder(kCCTableViewFillTopDown);

	CCPoint strengthenTestPosition = strengthenTestButton->getPosition();
	strengthenTableView->setPosition(ccp(strengthenTestPosition.x, strengthenTestPosition.y - tableViewPanel->getContentSize().height));
	strengthenTableView->setDelegate(this);
	strengthenTableView->reloadData();

	addChild(uiLayer);
	addChild(strengthenTableView);

	setVisible(false);
	refresh();
	return true;
}
bool UIPageViewTest::init()
{
    if (UIScene::init())
    {
        CCSize screenSize = CCDirector::sharedDirector()->getWinSize();
        
        // Add a label in which the dragpanel events will be displayed
        m_pDisplayValueLabel = UILabel::create();
        m_pDisplayValueLabel->setText("Move by horizontal direction");
        m_pDisplayValueLabel->setFontName("Marker Felt");
        m_pDisplayValueLabel->setFontSize(32);
        m_pDisplayValueLabel->setAnchorPoint(ccp(0.5f, -1));
        m_pDisplayValueLabel->setPosition(ccp(screenSize.width / 2.0f, screenSize.height / 2.0f + m_pDisplayValueLabel->getContentSize().height * 1.5));
        m_pUiLayer->addWidget(m_pDisplayValueLabel);
        
        // Add the black background
        UILabel *alert = UILabel::create();
        alert->setText("PageView");
        alert->setFontName("Marker Felt");
        alert->setFontSize(30);
        alert->setColor(ccc3(159, 168, 176));
        alert->setPosition(ccp(screenSize.width / 2.0f, screenSize.height / 2.0f - alert->getRect().size.height * 2.925));
        m_pUiLayer->addWidget(alert);
        
        UIPanel *background = dynamic_cast<UIPanel*>(m_pUiLayer->getWidgetByName("background_Panel"));        
        
        // Create the page view
        UIPageView* pageView = UIPageView::create();
        pageView->setTouchEnable(true);
        pageView->setSize(CCSizeMake(240, 130));
        CCSize backgroundSize = background->getContentSize();
        pageView->setPosition(ccp((screenSize.width - backgroundSize.width) / 2 +
                                  (backgroundSize.width - pageView->getRect().size.width) / 2,
                                  (screenSize.height - backgroundSize.height) / 2 +
                                  (backgroundSize.height - pageView->getRect().size.height) / 2));
        
        for (int i = 0; i < 3; ++i)
        {
            UIPanel* panel = UIPanel::create();
            panel->setSize(CCSizeMake(240, 130));
            
            UIImageView* imageView = UIImageView::create();
            imageView->setTouchEnable(true);
            imageView->setScale9Enable(true);
            imageView->setTexture("cocosgui/scrollviewbg.png");
            imageView->setScale9Size(CCSizeMake(240, 130));
            imageView->setPosition(ccp(panel->getRect().size.width / 2, panel->getRect().size.height / 2));
            panel->addChild(imageView);
            
            UILabel* label = UILabel::create();
            label->setText(CCString::createWithFormat("page %d", (i + 1))->getCString());
            label->setFontName("Marker Felt");
            label->setFontSize(30);
            label->setColor(ccc3(192, 192, 192));
            label->setPosition(ccp(panel->getRect().size.width / 2, panel->getRect().size.height / 2));
            panel->addChild(label);
            
            pageView->addPage(panel);
        }
        
        m_pUiLayer->addWidget(pageView);
        
        return true;
    }
    return false;
}
Exemple #24
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 GameLayer_GoldMarket::setVisible(bool visible)
{
    CCLayer::setVisible(visible);
    UIPanel* dayLoginPanel = dynamic_cast<UIPanel*>(goldMarket->getWidgetByName("Panel"));
    dayLoginPanel->setTouchEnable(visible);
}
bool WorldCup::init(){
    if ( !CCLayer::init() )
    {
        return false;
    }
    showYet = false;
    inUpdateData = false;
    oldOrNew = 0;
    lastRefreshTime = 0;
    inRefresh = false;
    lastUpdateIndex = 0;
    dict = CCDictionary::create();
    dict->retain();
    
    
    
    CCSize size = CCDirector::sharedDirector()->getVisibleSize();
    CCLog("winSize %f %f", size.width, size.height);
    
    UILayer *lay = UILayer::create();
    addChild(lay);
    //lay->setPosition(ccp(size.width/2, size.height/2));
    //lay->setContentSize(size);
    
    

    //w = GUIReader::shareReader()->widgetFromJsonFile("gui/ballUI_1.json");
    
    w = GUIReader::shareReader()->widgetFromJsonFile("gui/ballUI_1_0.json");
    lay->addWidget(w);
    CCSize rs = w->getSize();
    CCLog("rootSize %f %f", rs.width, rs.height);
    w->setSizeType(SIZE_ABSOLUTE);
    w->setSize(size);
    
    Button *conf = static_cast<Button*>(UIHelper::seekWidgetByName(w, "selfinfo"));
    conf->addTouchEventListener(this, toucheventselector(WorldCup::onConf));
    /*
    
    */
    /*
    Button *fri = static_cast<Button*>(UIHelper::seekWidgetByName(w, "Button_5"));
    fri->addTouchEventListener(this, toucheventselector(WorldCup::onFri));
    */
    
    lv = static_cast<UIListView*>(UIHelper::seekWidgetByName(w, "listView"));
    lv->addEventListenerListView(this, listvieweventselector(WorldCup::onListview));
    lv->addEventListenerScrollView(this, scrollvieweventselector(WorldCup::onScroll));
    
    
    UIPanel *pan = static_cast<UIPanel*>(UIHelper::seekWidgetByName(w, "dayPanel"));
    pan->setEnabled(false);
    
    pc = pan->clone();
    pc->setVisible(true);
    pc->setEnabled(true);
    pc->retain();
    
    dlab = static_cast<UILabel*>(UIHelper::seekWidgetByName(pc, "date"));
    
    UIPanel *cupPanel = static_cast<UIPanel*>(UIHelper::seekWidgetByName(w, "cupPanel"));
    cupPanel->setEnabled(false);
    //整个Panel 大小一样的 按钮
    //Button *full = static_cast<Button*>(UIHelper::seekWidgetByName(cupPanel, "full"));
    //full->setVisible(false);
    
    
    cp = cupPanel->clone();
    cp->setVisible(true);
    cp->setEnabled(true);
    cp->retain();
    
    
    /*
    UIPanel *pan = static_cast<UIPanel*>(UIHelper::seekWidgetByName(w, "dayPanel"));
    UIListView *lv = static_cast<UIListView*>(UIHelper::seekWidgetByName(w, "listView"));
    
    UIWidget *pc = pan->clone();
    pc->setVisible(true);
    
    lv->pushBackCustomItem(pc);
    
    UIPanel *cupPanel = static_cast<UIPanel*>(UIHelper::seekWidgetByName(w, "cupPanel"));
    UIWidget *cp = cupPanel->clone();
    cp->setVisible(true);
    lv->pushBackCustomItem(cp);
    
    lv->pushBackCustomItem(pc->clone());
    lv->pushBackCustomItem(cp->clone());
    lv->pushBackCustomItem(cp->clone());
    lv->pushBackCustomItem(cp->clone());
    */
    scheduleUpdate();
    
    return true;
    
}