コード例 #1
0
ファイル: SportMediator.cpp プロジェクト: Dream-Hat/mdsj
bool SportLayer::initWidgets4PanelSportFriend(Layout* _sportFriendLay)
{
	bool bRet = false;
	do 
	{
		UIWidget* bgSportFriend = _sportFriendLay->getChildByName("bg_friend");
		UITextButton* txtBtnSportFriendBack = dynamic_cast<UITextButton*>(bgSportFriend->getChildByName("txtBtn_friend_back"));
		txtBtnSportFriendBack->addReleaseEvent(this, coco_releaseselector(SportLayer::panelSportFriendCallback));
		txtBtnSportFriendBack->setWidgetTag(sportFriendBackBtnTag);

		UITextButton* txtBtnSportFriendOLPlayerTag = dynamic_cast<UITextButton*>(bgSportFriend->getChildByName("txtBtn_friend_olplayer_tag"));
		txtBtnSportFriendOLPlayerTag->addReleaseEvent(this, coco_releaseselector(SportLayer::panelSportFriendCallback));
		txtBtnSportFriendOLPlayerTag->setWidgetTag(sportFriendOLPlayerTagBtnTag);

		UITextButton* txtBtnSportFriendClubTag = dynamic_cast<UITextButton*>(bgSportFriend->getChildByName("txtBtn_friend_club_tag"));
		txtBtnSportFriendClubTag->addReleaseEvent(this, coco_releaseselector(SportLayer::panelSportFriendCallback));
		txtBtnSportFriendClubTag->setWidgetTag(sportFriendClubTagBtnTag);

		UITextButton* txtBtnSportFriendFriendTag = dynamic_cast<UITextButton*>(bgSportFriend->getChildByName("txtBtn_friend_friend_tag"));
		txtBtnSportFriendFriendTag->addReleaseEvent(this, coco_releaseselector(SportLayer::panelSportFriendCallback));
		txtBtnSportFriendFriendTag->setWidgetTag(sportFriendFriendTagBtnTag);

		//friend list
		UIScrollView* scvwFriendList = dynamic_cast<UIScrollView*>(bgSportFriend->getChildByName("scvw_friend_list"));
		
		//scvwFriendList->scrollToTop();
		//listitem 
		int itemCount = 10;
		CCString* name = CCString::createWithFormat("ui/SportUI/%s.json",m_allListItemNames->valueForKey(friendListItem)->getCString() );

		Layout* pListItem = dynamic_cast<Layout*>(CCUIHELPER->createWidgetFromJsonFile(name->getCString()	));
		CC_BREAK_IF(! pListItem);
		pListItem->setPosition(CCPointZero);
		scvwFriendList->addChild(pListItem);
		CCSize scvwSize = scvwFriendList->getInnerContainerSize();
		scvwFriendList->setInnerContainerSize(CCSizeMake(scvwSize.width, pListItem->getContentSize().height * itemCount));
		for(int i=1; i<itemCount; i++){
			pListItem = dynamic_cast<Layout*>(CCUIHELPER->createWidgetFromJsonFile(name->getCString()	));
			CC_BREAK_IF(! pListItem);
			pListItem->setPosition(ccp(0,i*(pListItem->getContentSize().height)));
			scvwFriendList->addChild(pListItem);
		}
		

		bRet = true;
	} while (0);
	return bRet;
}
コード例 #2
0
ファイル: GameEndBuy.cpp プロジェクト: joyfish/Bejeweled
void GameEndBuy::init(void *data){
    m_tips = CCUIHELPER->createWidgetFromJsonFile("GameEndBuy.json");
    UIWidget* mCoin = m_tips->getChildByName("mCoin");
    UILabelBMFont* coin_num = (UILabelBMFont*)mCoin->getChildByName("num");
    IntToString(_coin, G::G_getCoin());
    coin_num->setText(_coin);
    UILabelBMFont* title = (UILabelBMFont*)m_tips->getChildByName("titile");
    UILabelBMFont* des = (UILabelBMFont*)m_tips->getChildByName("des");
    UILabelBMFont* price = (UILabelBMFont*)m_tips->getChildByName("price");
    UIImageView* icon = (UIImageView*)m_tips->getChildByName("icon");
    CCDictionary* _dic = CCDictionary::createWithContentsOfFile("data/normaltips.plist");
    
    if (G::g_game_lose_conditions[LOSE_CONDITION_TIME]>0) {
        CCString* _title_str = (CCString*)_dic->objectForKey("game_end_des_time");
        CCString* _des_str = (CCString*)_dic->objectForKey("game_end_tool_time");
        IntToString(_price, tool_prices[TOOL_TYPE_TIME]*15/10);
        icon->setTexture("tools/icon_0.png");
        title->setText(_title_str->getCString());
        des->setText(_des_str->getCString());
        price ->setText(_price);
    }else{
        CCString* _title_str = (CCString*)_dic->objectForKey("game_end_des_step");
        CCString* _des_str = (CCString*)_dic->objectForKey("game_end_tool_step");
        IntToString(_price, tool_prices[TOOL_TYPE_STEP]*15/10);
        icon->setTexture("tools/icon_1.png");
        title->setText(_title_str->getCString());
        des->setText(_des_str->getCString());
        price ->setText(_price);
    }
    _dic->release();
}
コード例 #3
0
void SelectMenuView::onPageViewMove( CCObject *pSender, PageViewEventType type )
{
	switch (type)
	{
	case PAGEVIEW_EVENT_TURNING:
		{
			char tmp[32];
			UIPageView* pageView = dynamic_cast<UIPageView*>(pSender);
			// pageView->getCurPageIndex()
			UIWidget* widget = this->getWidgetByName("bottomUIWidget");
			UIWidget* selectedPoint = widget->getChildByName("selected");
			sprintf(tmp,"unselect%d",pageView->getCurPageIndex() + 1);
			UIWidget* unselectedPoint = widget->getChildByName(tmp);
			selectedPoint->setPosition(unselectedPoint->getPosition());
		}
		break;
	}
}
コード例 #4
0
void UIComponentTest::defaultPlay()
{

	CCComRender *render = static_cast<CCComRender*>(m_rootNode->getChildByTag(10025)->getComponent("GUIComponent"));
	cocos2d::ui::TouchGroup* touchGroup = static_cast<cocos2d::ui::TouchGroup*>(render->getNode());
	UIWidget* widget = static_cast<UIWidget*>(touchGroup->getWidgetByName("Panel_154"));
	UIButton* button = static_cast<UIButton*>(widget->getChildByName("Button_156"));
	button->addTouchEventListener(this, toucheventselector(UIComponentTest::touchEvent));

}
コード例 #5
0
void SelectMenuView::noticeUnlock( int beautyIndex )
{
	if( beautyIndex > 0 )
	{// unlock update
		UIWidget* widget = this->getWidgetByName("scrollView")->getChildByTag( beautyIndex + CARD_TAG );
		widget->getChildByName("lock")->setVisible(false);
	}
	UIWidget* bg = _panelUnlock->getChildByName("panelLock_bg");
	bg->stopAllActions();
	bg->runAction(CCSequence::create(CCScaleTo::create(0.3f,0.1f),CCCallFunc::create(this,callfunc_selector(SelectMenuView::_hidePanelUnlock)),NULL));
}
コード例 #6
0
ファイル: SportMediator.cpp プロジェクト: Dream-Hat/mdsj
bool SportLayer::initWidgets4PanelSportRule(Layout* _sportRuleLay)
{
	bool bRet = false;
	do 
	{
		UIWidget* bgSportRule = _sportRuleLay->getChildByName("bg_rule");
		UITextButton* txtBtnSportRuleBack = dynamic_cast<UITextButton*>(bgSportRule->getChildByName("txtBtn_rule_back"));
		txtBtnSportRuleBack->addReleaseEvent(this, coco_releaseselector(SportLayer::panelSportRuleCallback));
		txtBtnSportRuleBack->setWidgetTag(sportRuleBackBtnTag);

		bRet = true;
	} while (0);
	return bRet;
}
コード例 #7
0
ファイル: SportMediator.cpp プロジェクト: Dream-Hat/mdsj
bool SportLayer::initWidgets4PanelSport(Layout* _sportLay)
{
	bool bRet = false;
	do 
	{
		//btn back
		UIWidget* bgSport = _sportLay->getChildByName("bg_sport");
		UITextButton* txtBtnSportBack = dynamic_cast<UITextButton*>(bgSport->getChildByName("txtBtn_sport_back"));
		txtBtnSportBack->addReleaseEvent(this, coco_releaseselector(SportLayer::closeBtnCallBack));
		//btn rule
		UITextButton* txtBtnSportRule = dynamic_cast<UITextButton*>(bgSport->getChildByName("txtBtn_sport_rule"));
		txtBtnSportRule->addReleaseEvent(this, coco_releaseselector(SportLayer::panelSportCallback));
		txtBtnSportRule->setWidgetTag(sportRuleBtnTag);
		//btn start
		UITextButton* txtBtnSportStart = dynamic_cast<UITextButton*>(bgSport->getChildByName("txtBtn_sport_start"));
		txtBtnSportStart->addReleaseEvent(this, coco_releaseselector(SportLayer::panelSportCallback));
		txtBtnSportStart->setWidgetTag(sportStartBtnTag);
		//btn top
		UITextButton* txtBtnSportTop = dynamic_cast<UITextButton*>(bgSport->getChildByName("txtBtn_sport_top"));
		txtBtnSportTop->addReleaseEvent(this, coco_releaseselector(SportLayer::panelSportCallback));
		txtBtnSportTop->setWidgetTag(sportTopBtnTag);
		//btn clear
		UITextButton* txtBtnSportClear = dynamic_cast<UITextButton*>(bgSport->getChildByName("txtBtn_sport_clear"));
		txtBtnSportClear->addReleaseEvent(this, coco_releaseselector(SportLayer::panelSportCallback));
		txtBtnSportClear->setWidgetTag(sportClearBtnTag);
		//btn sport reward obtain
		UIWidget* bgSportReward = bgSport->getChildByName("bg_sport_reward");
		UITextButton* txtBtnRewardObtain = dynamic_cast<UITextButton*>(bgSportReward->getChildByName("txtBtn_reward_obtain"));
		txtBtnRewardObtain->addReleaseEvent(this, coco_releaseselector(SportLayer::panelSportCallback));
		txtBtnRewardObtain->setWidgetTag(sportRewardObtainBtnTag);
		//btn sport player seat invite 
		UIWidget* bgSportPlayerSeat = bgSport->getChildByName("bg_sport_player_seat");
		UIButton* txtBtnSeatInvite = dynamic_cast<UIButton*>(bgSportPlayerSeat->getChildByName("btn_seat_invite"));
		txtBtnSeatInvite->addReleaseEvent(this, coco_releaseselector(SportLayer::panelSportCallback));
		txtBtnSeatInvite->setWidgetTag(sportPlayerSeatInivteBtnTag);
		bRet = true;
	} while (0);
	return bRet;
}
コード例 #8
0
ファイル: SportMediator.cpp プロジェクト: Dream-Hat/mdsj
bool SportLayer::initWidgets4PanelSportTop(Layout* _sportTopLay)
{
	bool bRet = false;
	do 
	{
		UIWidget* bgSportRule = _sportTopLay->getChildByName("bg_top");
		UITextButton* txtBtnSportTopWinRatetag = dynamic_cast<UITextButton*>(bgSportRule->getChildByName("txtBtn_top_win_rate_tag"));
		txtBtnSportTopWinRatetag->addReleaseEvent(this, coco_releaseselector(SportLayer::panelSportTopCallback));
		txtBtnSportTopWinRatetag->setWidgetTag(sportTopWinRateTagBtnTag);

		UITextButton* txtBtnSportTopWinCnttag = dynamic_cast<UITextButton*>(bgSportRule->getChildByName("txtBtn_top_win_cnt_tag"));
		txtBtnSportTopWinCnttag->addReleaseEvent(this, coco_releaseselector(SportLayer::panelSportTopCallback));
		txtBtnSportTopWinCnttag->setWidgetTag(sportTopWinCntTagBtnTag);

		UITextButton* txtBtnSportTopScoreTag = dynamic_cast<UITextButton*>(bgSportRule->getChildByName("txtBtn_top_score_tag"));
		txtBtnSportTopScoreTag->addReleaseEvent(this, coco_releaseselector(SportLayer::panelSportTopCallback));
		txtBtnSportTopScoreTag->setWidgetTag(sportTopScoreTagBtnTag);

		UITextButton* txtBtnSportTopBack = dynamic_cast<UITextButton*>(bgSportRule->getChildByName("txtBtn_top_back"));
		txtBtnSportTopBack->addReleaseEvent(this, coco_releaseselector(SportLayer::panelSportTopCallback));
		txtBtnSportTopBack->setWidgetTag(sportTopBackBtnTag);

		UITextButton* txtBtnSportTopPlayerNicknameTag = dynamic_cast<UITextButton*>(bgSportRule->getChildByName("txtBtn_player_nickname_tag"));
		txtBtnSportTopPlayerNicknameTag->addReleaseEvent(this, coco_releaseselector(SportLayer::panelSportTopCallback));
		txtBtnSportTopPlayerNicknameTag->setWidgetTag(sportTopPlayerNicknameBtnTag);

		//friend list
		UIScrollView* scvwTopList = dynamic_cast<UIScrollView*>(bgSportRule->getChildByName("scvw_top_list"));
		CC_BREAK_IF(! scvwTopList);
		int itemCount = 10;
		//listitem 
		CCString* name = CCString::createWithFormat("ui/SportUI/%s.json",m_allListItemNames->valueForKey(topListItem)->getCString() );
		Layout* pListItem = dynamic_cast<Layout*>(CCUIHELPER->createWidgetFromJsonFile(name->getCString()	));
		CC_BREAK_IF(! pListItem);
		pListItem->setPosition(CCPointZero);
		scvwTopList->addChild(pListItem);

		CCSize scvwSize = scvwTopList->getInnerContainerSize();
		scvwTopList->setInnerContainerSize(CCSizeMake(scvwSize.width, pListItem->getContentSize().height * itemCount));

		for(int i=1; i<itemCount; i++){
			pListItem = dynamic_cast<Layout*>(CCUIHELPER->createWidgetFromJsonFile(name->getCString()	));
			CC_BREAK_IF(! pListItem);
			pListItem->setPosition(ccp(0,i*(pListItem->getContentSize().height)));
			scvwTopList->addChild(pListItem);
		}

		bRet = true;
	} while (0);
	return bRet;
}
コード例 #9
0
bool UIListViewExTest_Horizontal::init()
{
    if (UIScene::init())
    {
        CCSize widgetSize = m_pWidget->getSize();
        
        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(widgetSize.width / 2.0f, widgetSize.height / 2.0f + m_pDisplayValueLabel->getContentSize().height * 1.5));
        m_pUiLayer->addWidget(m_pDisplayValueLabel);
        
        
        UILabel* alert = UILabel::create();
        alert->setText("ListView horizontal");
        alert->setFontName("Marker Felt");
        alert->setFontSize(30);
        alert->setColor(ccc3(159, 168, 176));
        alert->setPosition(ccp(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 3.075));
        m_pUiLayer->addWidget(alert);
        
        Layout* background = dynamic_cast<Layout*>(m_pUiLayer->getWidgetByName("background_Panel"));
        CCSize backgroundSize = background->getContentSize();
        
        
        // create list view data
        m_array = CCArray::create();
        CC_SAFE_RETAIN(m_array);
        for (int i = 0; i < 20; ++i)
        {
            CCString* ccstr = CCString::createWithFormat("listview_item_%d", i);
            m_array->addObject(ccstr);
        }
        
        
        // Create the list view
        UIListView* listView = UIListView::create();
        // set list view direction
        listView->setDirection(SCROLLVIEW_DIR_HORIZONTAL);
        listView->setTouchEnabled(true);
        listView->setBounceEnabled(true);
        listView->setBackGroundImage("cocosgui/green_edit.png");
        listView->setBackGroundImageScale9Enabled(true);
        listView->setSize(CCSizeMake(240, 130));
        listView->setPosition(ccp((widgetSize.width - backgroundSize.width) / 2 +
                                    (backgroundSize.width - listView->getSize().width) / 2,
                                    (widgetSize.height - backgroundSize.height) / 2 +
                                    (backgroundSize.height - listView->getSize().height) / 2));
        listView->addEventListenerListView(this, listvieweventselector(UIListViewExTest_Horizontal::selectedItemEvent));
        m_pUiLayer->addWidget(listView);
        
        
        // create model
        UIButton* default_button = UIButton::create();
        default_button->setName("TextButton");
        default_button->setTouchEnabled(true);
        default_button->loadTextures("cocosgui/backtotoppressed.png", "cocosgui/backtotopnormal.png", "");
        
        Layout* default_item = Layout::create();
        default_item->setTouchEnabled(true);
        default_item->setSize(default_button->getSize());
        default_button->setPosition(ccp(default_item->getSize().width / 2, default_item->getSize().height / 2));
        default_item->addChild(default_button);
        
        // set model
        listView->setItemModel(default_item);
        
        // add default item
        int count = m_array->count();
        for (int i = 0; i < count / 4; ++i)
        {
            listView->pushBackDefaultItem();
        }
        // insert default item
        for (int i = 0; i < count / 4; ++i)
        {
            listView->insertDefaultItem(0);
        }
        
        // add custom item
        for (int i = 0; i < count / 4; ++i)
        {
            UIButton* custom_button = UIButton::create();
            custom_button->setName("TextButton");
            custom_button->setTouchEnabled(true);
            custom_button->loadTextures("cocosgui/button.png", "cocosgui/buttonHighlighted.png", "");
            custom_button->setScale9Enabled(true);
            custom_button->setSize(default_button->getSize());
            
            Layout *custom_item = Layout::create();
            custom_item->setSize(custom_button->getSize());
            custom_button->setPosition(ccp(custom_item->getSize().width / 2, custom_item->getSize().height / 2));
            custom_item->addChild(custom_button);
            
            listView->pushBackCustomItem(custom_item);
        }
        // insert custom item
        CCArray *items = listView->getItems();
        int items_count = items->count();
        for (int i = 0; i < count / 4; ++i)
        {
            UIButton* custom_button = UIButton::create();
            custom_button->setName("TextButton");
            custom_button->setTouchEnabled(true);
            custom_button->loadTextures("cocosgui/button.png", "cocosgui/buttonHighlighted.png", "");
            custom_button->setScale9Enabled(true);
            custom_button->setSize(default_button->getSize());
            
            Layout *custom_item = Layout::create();
            custom_item->setSize(custom_button->getSize());
            custom_button->setPosition(ccp(custom_item->getSize().width / 2, custom_item->getSize().height / 2));
            custom_item->addChild(custom_button);
            
            listView->insertCustomItem(custom_item, items_count);
        }
        
        // set item data
        items_count = items->count();
        for (int i = 0; i < items_count; ++i)
        {
            UIWidget *item = listView->getItem(i);
            UIButton *button = static_cast<UIButton*>(item->getChildByName("TextButton"));
            int index = listView->getIndex(item);
            button->setTitleText(static_cast<CCString*>(m_array->objectAtIndex(index))->getCString());
        }
        
        // remove last item
        listView->removeLastItem();
        
        // remove item by index
        items_count = items->count();
        listView->removeItem(items_count - 1);        
        
        // set all items layout gravity
        listView->setGravity(LISTVIEW_GRAVITY_CENTER_VERTICAL);
        
        // set items margin
        listView->setItemsMargin(2);
        
        return true;
    }
    
    return false;
}
コード例 #10
0
ファイル: HoleModeResult.cpp プロジェクト: joyfish/Bejeweled
void HoleModeResult::startAnim(){
        HCCWindow::startAnim();
    if (m_star>0&&m_star<=4) {
        for (int i=0; i<m_star; i++) {
            IntToStringFormat(_starName, "gift_%d", i);
            UIWidget* mStars = m_tips->getChildByName(_starName);
            mStars->setVisible(true);
            PopNodeQ(mStars, 0.6f+0.4f*i);
        }
    }
    UIWidget* mLight = m_tips->getChildByName("light");
    UIWidget* btn_home = m_tips->getChildByName("btn_home");
    UIWidget* btn_next = m_tips->getChildByName("btn_next");
    UIWidget* mTitle = m_tips->getChildByName("title_bg");
    
    mLight->setVisible(false);
    mLight->runAction(CCRepeatForever::create(CCRotateBy::create(6.0f, 360)));
    mLight->runAction(CCSequence::create(CCDelayTime::create(0.6f+0.4f*m_star),CCShow::create(),NULL));
    mTitle->runAction(CCSequence::create(CCDelayTime::create(0.6f+0.4f*m_star),CCRepeat::create(CCSequence::create(CCScaleTo::create(0.15f, 1.1f),CCScaleTo::create(0.3f, 1.0f),NULL),99),NULL));
    if (m_rewards) {
        for (unsigned int i=0; i<m_rewards->count()&&i<4; i++) {
            RewardInfo* info = (RewardInfo*)m_rewards->objectAtIndex(i);
            IntToStringFormat(_rName,"reward_%d",i+1);
            UIImageView* mReward = (UIImageView*)m_tips->getChildByName(_rName);
            IntToStringFormat(_iconName, "icons/icon_reward_%d.png",info->id);
            mReward->setTexture(_iconName);
            UILabelAtlas* num = (UILabelAtlas*)mReward->getChildByName("count");
            IntToStringFormat(_count, ":%d",info->count);
            num->setStringValue(_count);
            mReward->setVisible(true);
            PopNodeQ(mReward, 0.4f+0.4f*m_star);
        }
        m_rewards->removeAllObjects();
        CC_SAFE_DELETE(m_rewards);
    }

    PopNode(btn_home, 0.4f+0.4f*m_star);
    PopNode(btn_next, 0.8f+0.4f*m_star);
    
    btn_home->addReleaseEvent(this, coco_releaseselector(HoleModeResult::onHome));
    btn_next->addReleaseEvent(this, coco_releaseselector(HoleModeResult::onRestart));
    
    UIWidget* mContainer = m_tips->getChildByName("Container");
    
    const int count = 8;
    
    UILabelAtlas* mNums[count];
    for (int i=0; i<count; i++) {
        IntToStringFormat(mName, "m_%d", i);
        mNums[i] = (UILabelAtlas*)mContainer->getChildByName(mName);
    }
    SetDepthNum(mNums, count, m_totaldepth)
//    {
//        int tmpNum = m_totaldepth;
//        
//        for (int i=0; i<count; i++) {
//            IntToString(n, tmpNum%10)
//            tmpNum/=10;
//            mNums[i]->setStringValue(n);
//        }
//    }
    ScrollDepthNum(mNums, count, m_totaldepth, m_totaldepth+m_currentdepth);
//    {
//        int pre = m_totaldepth;
//        int current = m_totaldepth+m_currentdepth;
//        for (int i=0; i<count; i++) {
//            if (current%10==pre%10) {
//                current/=10;
//                pre/=10;
//                continue;
//            }
//            IntToString(n, current%10);
//            current/=10;
//            pre/=10;
//            CCPoint pos = mNums[i]->getPosition();
//            UIWidget* parent = mNums[i]->getParent();
//            mNums[i]->runAction(CCSequence::create(CCDelayTime::create(0.5f), CCMoveBy::create(0.3f, ccp(0, 50)),CCCallFuncND::create(this, callfuncND_selector(G::G_callbackRemoveUIWidget2),mNums[i]),NULL));
//            mNums[i] = UILabelAtlas::create();
//            mNums[i]->setProperty(n, "numbers/num3.png", 20, 28, "0");
//            mNums[i]->setPosition(ccp(pos.x,pos.y-50));
//            parent->addChild(mNums[i]);
//            mNums[i]->runAction(CCSequence::create(CCDelayTime::create(0.5f), CCMoveBy::create(0.3f, ccp(0, 50)),NULL));
//        }
//    }
    

}
コード例 #11
0
ファイル: GameEndBuy.cpp プロジェクト: joyfish/Bejeweled
void GameEndBuy::update(float dt){
    UIWidget* mCoin = m_tips->getChildByName("mCoin");
    UILabelBMFont* coin_num = (UILabelBMFont*)mCoin->getChildByName("num");
    IntToString(_coin, G::G_getCoin());
    coin_num->setText(_coin);
}
コード例 #12
0
bool SelectMenuView::init()
{
	char tmp[32];
	UILayer::init();

	// background
	UIImageView* background = UIImageView::create();
	background->loadTexture("level_bg.jpg",UI_TEX_TYPE_PLIST);
	background->setAnchorPoint(CCPoint(0,0));
	this->addWidget(background);

	// Beauty Card
	UIPageView* scrollView = UIPageView::create();
	scrollView->setTouchEnabled(true);
	scrollView->setSize( CCSize( GAME_WIDTH, GAME_HEIGHT * 3 / 4 ) );
	scrollView->setPosition(CCPoint( 0, GAME_HEIGHT/8 ));
	scrollView->setName("scrollView");

	UILayout* widgetBeautyCard = (UILayout*)GUIReader::shareReader()->widgetFromJsonFile("BeautyCard.ExportJson");

	for( int i = 0; i < MAX_BEAUTY_NUM; i++ )
	{
		Layout* layout = Layout::create();
		layout->setSize(CCSize(GAME_WIDTH, GAME_HEIGHT * 3 / 4));

		ScrollButton* button = ScrollButton::create();
		button->setSize(CCSize(160,200));

		UILayout* widget = NULL;
		if(i == 0)
		{
			widget = widgetBeautyCard;
		}
		else
		{
			widget =  static_cast<UILayout*>(widgetBeautyCard->clone());
		}

		widget->setAnchorPoint(CCPoint( 0.5f, 0.5f));
		button->setPosition(CCPoint(GAME_WIDTH/2,GAME_HEIGHT* 3 / 8));
		sprintf(tmp,"beautyCard%d",i);
		button->setName(tmp);
		//widget->setPosition( Point( GAME_WIDTH * i, 0 ) );
		button->setTag( i + CARD_TAG );

		button->addChild(widget);
		layout->addChild( button );
		scrollView->addPage( layout );
	}

	//CC_SAFE_DELETE(widgetTree);
	//CC_SAFE_DELETE(jsonDict);
	//CC_SAFE_DELETE_ARRAY(des);

	scrollView->addEventListener(this, pagevieweventselector(SelectMenuView::onPageViewMove));
	this->addWidget( scrollView );
	
	// bottom 
	UIWidget* bottomWidget = (UIWidget*)GUIReader::shareReader()->widgetFromJsonFile("SelectUI.ExportJson");
	bottomWidget->setName("bottomUIWidget");
	this->addWidget( bottomWidget );

	// buttton
	UIButton* button_back = static_cast<UIButton*>( bottomWidget->getChildByName("Button_back") );
	UIButton* button_seal = static_cast<UIButton*>( bottomWidget->getChildByName("Button_seal") );
	button_back->addTouchEventListener(this,toucheventselector(SelectMenuView::onTouchButton));
	button_back->setTouchEnabled(true);
	button_back->setPressedActionEnabled(true);
	button_seal->addTouchEventListener(this,toucheventselector(SelectMenuView::onTouchButton));
	button_seal->setTouchEnabled(true);
	button_seal->setPressedActionEnabled(true);

	// Evil Mask panel
	_panelEvil = (UIWidget*)GUIReader::shareReader()->widgetFromJsonFile("PanelEvil.ExportJson");
	_panelEvil->retain();

	// unlock panel
	_panelUnlock = (UIWidget*)GUIReader::shareReader()->widgetFromJsonFile("PanelSelectLock.ExportJson");
	_panelUnlock->retain();

	return true;
}
コード例 #13
0
void SelectMenuView::noticeView(SelectMenuModel* model)
{
#pragma region RESET_SCROLL_RECT
	char tmp[32];
	UIPageView* scrollView = static_cast<UIPageView*>(this->getWidgetByName("scrollView"));
	for( int i = 0; i < MAX_BEAUTY_NUM; i++ )
	{
		UIWidget* widget = scrollView->getChildByTag( i + CARD_TAG );
		widget->addTouchEventListener(this , toucheventselector(SelectMenuView::onTouchBeautyCard));
		//UIImageView* card_bg = static_cast<UIImageView*>(widget->getChildByName("card_bg"));
		//card_bg->setTouchEnabled(true);
		//card_bg->addTouchEventListener(this , toucheventselector(SelectMenuView::touchBeautyCard));

		UILabelBMFont* nameTxt = static_cast<UILabelBMFont*>(widget->getChildByName("txt_name"));
		UILabelBMFont* timeTxt = static_cast<UILabelBMFont*>(widget->getChildByName("txt_time"));
		UIImageView* beautyHead = static_cast<UIImageView*>(widget->getChildByName("head"));
		UIImageView* beContinue = static_cast<UIImageView*>(widget->getChildByName("moreLevel"));
		UIImageView* passRibbon = static_cast<UIImageView*>(widget->getChildByName("lock"));
		UIImageView* hearts[MAX_HEART];
		UIImageView* stars[MAX_STAR];
		for( int n = 0; n < MAX_HEART; n++ )
		{
			sprintf( tmp, "heart%d",n+1 );
			hearts[n] = static_cast<UIImageView*>(widget->getChildByName(tmp));
			hearts[n]->setVisible(false);
			sprintf( tmp, "star%d",n+1 );
			stars[n] = static_cast<UIImageView*>(widget->getChildByName(tmp));
			stars[n]->setVisible(false);
		}

		if( i < REAL_BEAUTY_NUM )
		{
			BeautyData data = model->getBeautyData(i);
			// --------------------------- Setting ---------------------------
			//if( i < REAL_BEAUTY_NUM )
			//{
				sprintf( tmp , "head_%d.png" , i);
				beautyHead->loadTexture(tmp ,UI_TEX_TYPE_PLIST);
			//}
			nameTxt->setText( data.name );
			if(data.time>9) sprintf( tmp,"%d:00", data.time );
			else sprintf( tmp,"0%d:00", data.time );
			timeTxt->setVisible(true);
			timeTxt->setText(tmp);
			for ( int n = 0; n < MAX_STAR; n++ )
			{
				if( n < data.difficult ) stars[n]->setVisible(true);
				else stars[n]->setVisible(false);
			}
			int heartNum = model->getUserGainHeartNum(i);
			for ( int n = 0; n < MAX_HEART; n++ )
			{
				if( n < heartNum ) hearts[n]->setVisible(true);
				else hearts[n]->setVisible(false);
			}
			beContinue->setVisible(false);
			if(heartNum < 0)
			{// not pass && close
				passRibbon->setVisible(true);
			}
			else
			{// pass || open
				passRibbon->setVisible(false);
			}
		}
		/////////////
		else
		{
			if(i == MAX_BEAUTY_NUM - 1 )
			{
				beContinue->setVisible(true);
				beautyHead->loadTexture("head_9.png" ,UI_TEX_TYPE_PLIST);
			}
			else
			{
				sprintf( tmp , "head_%d.png" , i);
				beautyHead->loadTexture(tmp ,UI_TEX_TYPE_PLIST);
			}
			nameTxt->setText( "???????????" );
			timeTxt->setText("--:--");
			passRibbon->setVisible(false);
		}
	}
#pragma endregion
}