Пример #1
0
void IOSStoreLayer::initUI()
{
	//初始化背景
	m_pBg = CCSprite::create(ResManager::getManager()->getFilePathByLanguageType(g_storelayerPath+"main_shangdian_bg.png").c_str());
	this->addChild(m_pBg, 1, bg_tag);
	m_pBg->setPosition(ccp(this->getContentSize().width/2, this->getContentSize().height/2));

	m_pKaibaoxiangNode = CCScale9Sprite::create(ResManager::getManager()->getSharedFilePath(g_seasonlayerPath+"nodebg.png").c_str());
	m_pKaibaoxiangNode->ignoreAnchorPointForPosition(false);
	m_pKaibaoxiangNode->setAnchorPoint(ccp(0.5f, 0.5f));
	m_pKaibaoxiangNode->setContentSize(m_pBg->getContentSize());
	m_pKaibaoxiangNode->setPosition(ccp(m_pBg->getContentSize().width/2, m_pBg->getContentSize().height/2));
	m_pBuyStarNode = CCScale9Sprite::create(ResManager::getManager()->getSharedFilePath(g_seasonlayerPath+"nodebg.png").c_str());
	m_pBuyStarNode->ignoreAnchorPointForPosition(false);
	m_pBuyStarNode->setAnchorPoint(ccp(0.5f, 0.5f));
	m_pBuyStarNode->setPosition(ccp(m_pBg->getContentSize().width/2, m_pBg->getContentSize().height/2));
	m_pBuyStarNode->setContentSize(m_pBg->getContentSize());

	m_pBg->addChild(m_pKaibaoxiangNode, 3, kaibaoxiang_node_tag);
	m_pBg->addChild(m_pBuyStarNode, 3, buystar_node_tag);

	m_pBgMenu = CCMenu::create();
	m_pBgMenu->setPosition(CCPointZero);
	m_pBg->addChild(m_pBgMenu, 2);

	//左上角提示背景
	CCSprite* pTip = CCSprite::create(ResManager::getManager()->getSharedFilePath(g_storelayerPath+"main_shangdian_tishi.png").c_str());
	m_pBg->addChild(pTip, 0, tip_bg_tag);
	pTip->setPosition(ccp(pTip->getContentSize().width/2 - 25,
		m_pBg->getContentSize().height-pTip->getContentSize().height/2 - 30));

	//左上角提示字符串
	CCLabelTTF* pTipStr = CCLabelTTF::create(LFStrings::getValue("ShangdiangTipStr_lefttop_juqing").c_str(), fontStr_katong, 24, CCSizeMake(210, 80), kCCTextAlignmentLeft);
	m_pBg->addChild(pTipStr, 1, lefttop_tip_str_tag);
	pTipStr->setPosition(ccp(pTip->getPositionX() + 20, pTip->getPositionY() - 25));
	pTipStr->setString("");

	//中间提示字符
	CCLabelTTF* pTipCenterStr = CCLabelTTF::create(LFStrings::getValue("ShangdiangTipStr_center_01").c_str(), fontStr_katong, 24);
	m_pBg->addChild(pTipCenterStr, 1, center_tip_str_tag);
	pTipCenterStr->setColor(ccc3(150, 60, 20));
	pTipCenterStr->setPosition(ccp(m_pBg->getContentSize().width/2,  m_pBg->getContentSize().height - 160));
	pTipCenterStr->setString("");
	
	//右边星星数
	CCLabelAtlas* lable = CCLabelAtlas::create(
		"0123456789",
		ResManager::getManager()->getSharedFilePath(g_seasonlayerPath+"season_star_amount.png").c_str(),
		30, 47,//24
		'0');
	m_pBg->addChild(lable, 1, star_count_str_tag);
	lable->setScale(0.6f);
	char charStarCount[10] = {}; 
	int iStarCount = GameInforEditer::getGameInfor()->getTotalFreeScore();
	sprintf(charStarCount, "%d", iStarCount);
	lable->setString(charStarCount);
	lable->setPosition(ccp(m_pBg->getContentSize().width - 120, m_pBg->getContentSize().height - 175));

	//右边字符
	CCSprite* pShuzi = CCSprite::create(ResManager::getManager()->getFilePathByLanguageType(g_seasonlayerPath+"season_amount.png").c_str());
	m_pBg->addChild(pShuzi, 1);
	pShuzi->setScale(0.6f);
	pShuzi->setPosition(ccp(lable->getPositionX() - 50, pTipCenterStr->getPositionY()));

	//右边星星图标
	CCSprite* pXingxing = CCSprite::create(ResManager::getManager()->getSharedFilePath(g_xiaogk+"YX_start.png").c_str());
	m_pBg->addChild(pXingxing, 1);
	pXingxing->setPosition(ccp(pShuzi->getPositionX() - 50, pShuzi->getPositionY()));
}
Пример #2
0
void IOSStoreLayer::showItemsNode()
{
	int iTotalCount = 1;
	int iPrice = 10;
	int xcount = 1;
	int ycount = 1;
	CCSize size = CCSizeMake(120, 190);

	if (m_bBaoxiangBuyTenTimes)
	{
		iTotalCount = 10;
		size.width = 820;
		size.height = 350;
		xcount = 5;
		ycount = 2;
		iPrice = 95;
	}

	iTotalCount = this->getKaiBaoxiangRsqData().size();
	if (iTotalCount >= 11)
	{
		xcount = 6;
	}

	if (iTotalCount == 2)
	{
		xcount = 2;
		size = CCSizeMake(140*2, 190);
	}

	IOSStoreLayerScrollView* pView = IOSStoreLayerScrollView::createView(size, iTotalCount, xcount, ycount);
	m_pGetItemNode->addChild(pView);
	pView->ignoreAnchorPointForPosition(false);
	pView->setAnchorPoint(ccp(0.5f, 0.5f));
	pView->setPosition(ccp(this->getContentSize().width/2, this->getContentSize().height/2 - 60));
	pView->setClickableCreater(pView);
	pView->prepareToDisplay();
	pView->setTouchEnabled(false);
	pView->setTag(getitem_scrollview_tag);

	//显示
	CCSprite* pSmallbg = CCSprite::create(ResManager::getManager()->getSharedFilePath(g_storelayerPath+"main_shangdian_anniu_zaikaishici_fujia.png").c_str());
	m_pGetItemNode->addChild(pSmallbg, 1);
	pSmallbg->setPosition(ccp(200, 100));

	//添加菜单
	CCMenu* pMenu = CCMenu::create();
	pMenu->setPosition(CCPointZero);
	m_pGetItemNode->addChild(pMenu, 2);
	
	//再开按钮
	CCMenuItemImage* pItem = NULL;
	int iStarCount = GameInforEditer::getGameInfor()->getTotalFreeScore();
	if (m_bBaoxiangBuyTenTimes)
	{
		pItem = CCMenuItemImage::create(
			ResManager::getManager()->getFilePathByLanguageType(g_storelayerPath+"main_shangdian_anniu_zaikaishici.png").c_str(),
			ResManager::getManager()->getFilePathByLanguageType(g_storelayerPath+"main_shangdian_anniu_zaikaishici_select.png").c_str(),
			this, menu_selector(IOSStoreLayer::menuBtnCallBack));
		pItem->setTag(buy_ten_again);
	}
	else
	{
		pItem = CCMenuItemImage::create(
			ResManager::getManager()->getFilePathByLanguageType(g_storelayerPath+"main_shangdian_anniu_zaikaiyici.png").c_str(),
			ResManager::getManager()->getFilePathByLanguageType(g_storelayerPath+"main_shangdian_anniu_zaikaiyici_select.png").c_str(),
			this, menu_selector(IOSStoreLayer::menuBtnCallBack));
		pItem->setTag(buy_one_again);
	}
	pItem->setPosition(ccp(pSmallbg->getPositionX() + pSmallbg->getContentSize().width/2 + pItem->getContentSize().width/2 - 30, 
		pSmallbg->getPositionY()));
	pMenu->addChild(pItem);

	//星星数量
	CCLabelAtlas* lable = CCLabelAtlas::create(
		"0123456789",
		ResManager::getManager()->getSharedFilePath(g_seasonlayerPath+"season_star_amount.png").c_str(),
		30, 47,//24
		'0');
	m_pGetItemNode->addChild(lable, 1, star_count_str_tag);
	lable->setAnchorPoint(ccp(0, 0.5));
	lable->setScale(0.6f);
	int iCount = 10;
	if (m_bBaoxiangBuyTenTimes)
	{
		iCount = 95;
	}
	char charStarCount[10] = {}; 
	sprintf(charStarCount, "%d", iCount);
	lable->setString(charStarCount);
	lable->setPosition(ccp(pItem->getPositionX()-pItem->getContentSize().width/2-lable->getContentSize().width/2 - 40, pSmallbg->getPositionY() - 3));

	//右边星星图标
	CCSprite* pXingxing = CCSprite::create(ResManager::getManager()->getSharedFilePath(g_xiaogk+"YX_start.png").c_str());
	m_pGetItemNode->addChild(pXingxing, 1);
	pXingxing->setPosition(ccp(lable->getPositionX() - 30, pSmallbg->getPositionY()));

	//星星数不够时,只显示确定按钮
	//确定按钮
	CCMenuItemImage* pOKItem = CCMenuItemImage::create(
		ResManager::getManager()->getFilePathByLanguageType(g_storelayerPath+"main_shangdian_anniu_quedingi.png").c_str(),
		ResManager::getManager()->getFilePathByLanguageType(g_storelayerPath+"main_shangdian_anniu_quedingi_select.png").c_str(),
		this, menu_selector(IOSStoreLayer::menuBtnCallBack));
	pOKItem->setTag(ok_btn_tag);
	pOKItem->setPosition(ccp(this->getContentSize().width/2 + pOKItem->getContentSize().width, pSmallbg->getPositionY()));
	pMenu->addChild(pOKItem);

	if (iStarCount < iPrice)
	{
		lable->setVisible(false);
		pXingxing->setVisible(false);
		pSmallbg->setVisible(false);
		pItem->setVisible(false);

		pOKItem->setPosition(ccp(this->getContentSize().width/2, pSmallbg->getPositionY()));
	}
	pMenu->setTouchPriority(kCCMenuHandlerPriority-5);
}