Exemple #1
0
bool AdvanceModePopularPackagesLayer::init()
{
	if(!Layer::init())
	{
		return false;
	}

	Sprite* pBackground = Sprite::create("AdvanceMode/background.png");
	pBackground->setPosition(Point(320.0f, 480.0f));
	this->addChild(pBackground);

	Sprite* pBackgroundPopUp = Sprite::create("AdvanceMode/panel-AM-long.png");
	pBackgroundPopUp->setPosition(Point(320.0f, 520.0f));
	this->addChild(pBackgroundPopUp);

	LabelTTF* pLabelMyPackage = LabelTTF::create("Popular Packages", "Arial", 35);
	pLabelMyPackage->setColor(ccc3(255.0f, 255.0f, 255.0f));
	pLabelMyPackage->setPosition(Point(200.0f, 630.0f));
	this->addChild(pLabelMyPackage);

	ButtonManagerNode* pButtonManagerNode = ButtonManagerNode::create();
	this->addChild(pButtonManagerNode);

	Sprite* m_pButtonAddMorePackageImage = Sprite::create("AdvanceMode/btn-add-small.png");
	ButtonNode* m_pButtonAddMorePackage = ButtonNode::createButtonSprite(m_pButtonAddMorePackageImage, CC_CALLBACK_1(AdvanceModePopularPackagesLayer::clickAddPackage, this));
	m_pButtonAddMorePackage->setPosition(Point(467.0f, 760.0f));
	pButtonManagerNode->addButtonNode(m_pButtonAddMorePackage);

	Sprite* m_pButtonPackageCodeImage = Sprite::create("AdvanceMode/text-box-small.png");
	//ButtonNode* m_pButtonPackageCode = ButtonNode::createButtonSprite(m_pButtonPackageCodeImage, CC_CALLBACK_1(AdvanceModePopularPackagesLayer::clickAddPackageCode, this));
	//m_pButtonPackageCode->setPosition(Point(213.0f, 760.0f));
	//pButtonManagerNode->addButtonNode(m_pButtonPackageCode);
	m_pButtonPackageCodeImage->setPosition(Point(213.0f, 760.0f));
	this->addChild(m_pButtonPackageCodeImage);


	m_pCodeEditBox = EditBox::create(Size(250.f, 50.f), Scale9Sprite::create("AdvanceMode/blank_edit.png"));
	m_pCodeEditBox->setFont("Arial", 30);
	m_pCodeEditBox->setFontColor(Color3B( 50, 50, 50));
    //m_pCodeEditBox->setPosition( Point(60.f, 260.f)); //Point(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y+visibleSize.height/4));
	m_pCodeEditBox->setPosition(Point(215.0f, 760.0f));
    //m_pCodeEditBox->setAnchorPoint(Point(0, 0.5f));
    m_pCodeEditBox->setPlaceHolder("Input code");
	m_pCodeEditBox->setInputFlag(EditBox::InputFlag::INTIAL_CAPS_ALL_CHARACTERS);
	//m_pCodeEditBox->setInputMode(EditBox::InputMode::ANY);
    //editCode->setDelegate(this);
    addChild(m_pCodeEditBox);



	LabelTTF* pLabelDescription = LabelTTF::create("Build your own vocab from http://petzzlegame.com", "Arial", 20);
	pLabelDescription->setColor(ccc3(255.0f, 255.0f, 255.0f));
	pLabelDescription->setPosition(Point(320.0f, 700.0f));
	this->addChild(pLabelDescription);

	LabelBMFont *pLabelTitle = LabelBMFont::create("ADVANCE MODE", "fonts/font-bechic.fnt");
	pLabelTitle->setAnchorPoint(Point(0.5f, 0.5f));
	pLabelTitle->setPosition(Point(320.0f, 880.0f));
	this->addChild(pLabelTitle);

	m_pBackgroundSlideShow = Sprite::create("AdvanceMode/panel-vocab-list.png");
	m_pBackgroundSlideShow->setPosition(Point(315.0f, 375.0f));
	this->addChild(m_pBackgroundSlideShow);

	m_pFooterNode = FooterNode::create();
	m_pFooterNode->removeBackground();
	m_pFooterNode->removeButtonFlashcard();
	this->addChild(m_pFooterNode);

	m_pSlideShow = ButtonManagerNode::create();
	m_pSlideShow->AllowSwipingBackground(true);
	m_pSlideShow->setPosition(Point(0.0f, 295.0f));

	ClipMaskNode* pClipMaskNode = ClipMaskNode::create();
	pClipMaskNode->setPosition(Point(28.0f, 150.0f));
	pClipMaskNode->setContentSize(Size(544.0f, 448.0f));
	pClipMaskNode->addChild(m_pSlideShow);
	m_pBackgroundSlideShow->addChild(pClipMaskNode);

	this->setTouchEnabled(true);
	this->setTouchMode(Touch::DispatchMode::ONE_BY_ONE);

	Breadcrumb::getInstance()->addSceneMode(SceneMode::kPopularPackage);

	m_pScrollManager = new ScrollManager();

	m_iConnectServer = UserDefault::getInstance()->getIntegerForKey("NumberConnectServer", 0);
	m_iConnectServer++;
	UserDefault::getInstance()->setIntegerForKey("NumberConnectServer", m_iConnectServer);

	PackageService::getInstance()->setInterfaceServiceCallBack(this);
	PackageService::getInstance()->getPackagePopular(0, 20, m_iConnectServer);

	m_iTotalPackage = 0;
	m_maxHeight = 0;

	m_pCustomPackageDownloadManager = new CustomPackageDownloadManager();
	m_pCustomPackageDownloadManager->SetDownloadPackageCompleteCallback(std::bind( &AdvanceModePopularPackagesLayer::OnDownloadPackageComplete, this, std::placeholders::_1));

	IconLoadingNode* iconLoadingNode = IconLoadingNode::create();
	iconLoadingNode->setTag(_TAG_ICON_LOADING_);
	iconLoadingNode->setPosition(320.0f, 400.0f);
	this->addChild(iconLoadingNode, _TAG_ICON_LOADING_);

	return true;
}
Exemple #2
0
bool FlashCardCollectionLayer::init()
{
	if(!Layer::init())
	{
		return false;
	}

	Sprite* pBackground = Sprite::create("FlashCard/background.png");
	pBackground->setPosition(Point(320.0f, 480.0f));
	this->addChild(pBackground);

	ButtonManagerNode* pButtonManagerNode = ButtonManagerNode::create();
	this->addChild(pButtonManagerNode);

	Sprite* pIconFlashCard = Sprite::create("FlashCard/flashcard_icon_btn.png");
	pIconFlashCard->setPosition(Point(-140.0f, 45.0f));

	Sprite* pButtonMiniGameSprite = Sprite::create("FlashCard/minigame-countdown.png");
	pButtonMiniGameSprite->addChild(pIconFlashCard);
	pButtonMiniGameSprite->setPosition(Point(154.0f, 0.0f));

	ButtonNode* pButtonMiniGame = ButtonNode::createButtonSprite(pButtonMiniGameSprite, CC_CALLBACK_1(FlashCardCollectionLayer::clickPlayMiniGame, this));
	pButtonMiniGame->setPosition(Point(320.0f, 810.0f));
	pButtonManagerNode->addButtonNode(pButtonMiniGame);


	m_iWordNew = WordTable::getInstance()->getNumberWordNew();
	m_iWordPlayMiniGame = WordTable::getInstance()->getNumberWordPlayMiniGame(getTimeLocalCurrent());

	m_pLabelMiniGame = LabelTTF::create("MINI GAME", "Arial", 30);
	m_pLabelMiniGame->setColor(ccc3(255.0f, 255.0f, 255.0f));
	m_pLabelMiniGame->setPosition(Point(148.0f, 47.0f));
	pButtonMiniGameSprite->addChild(m_pLabelMiniGame);

	m_iTimeCountDown = 0;
	if (m_iWordPlayMiniGame < 1 && m_iWordNew > 0)
	{
		unsigned long uMinTime = WordTable::getInstance()->getMinTimeNextPlayMiniGame();
		m_iTimeCountDown = uMinTime + _SECONDS_NEXT_PLAY_MINI_GAME_ - getTimeLocalCurrent();
		if (m_iTimeCountDown > 0)
		{
			m_pLabelMiniGame->setString(formatHMSToDisplay(m_iTimeCountDown).getCString());
			this->scheduleUpdate();
		}
		
	}

	if (m_iWordNew > 0)
	{
		Sprite* pIconNew = Sprite::create("FlashCard/noitify_msg.png");
		pIconNew->setPosition(Point(240.0f, 85.0f));
		pButtonMiniGameSprite->addChild(pIconNew);

		char sNumberNew[10];
		sprintf(sNumberNew, "%d", m_iWordNew);
		LabelTTF* pLabelNumber = LabelTTF::create(sNumberNew, "Arial", 25);
		pLabelNumber->setColor(ccc3(255.0f, 255.0f, 255.0f));
		pLabelNumber->setPosition(Point(22.0f, 20.0f));
		pIconNew->addChild(pLabelNumber);
	}

	Sprite* pBackgroundFlashcard = Sprite::create("FlashCard/panel-level_popup.png");
	pBackgroundFlashcard->setPosition(Point(320.0f, 415.0f));
	this->addChild(pBackgroundFlashcard);

	LabelBMFont *pLabelTitle = LabelBMFont::create("Flashcard Collection", "fonts/font-bechic.fnt");
	pLabelTitle->setAnchorPoint(Point(0.5f, 0.5f));
	pLabelTitle->setPosition(Point(320.0f, 673.0f));
	this->addChild(pLabelTitle);
	
	m_pFooterNode = FooterNode::create();
	m_pFooterNode->changeStatusButtonFlashcard(StatusButtonFlashcard::eNoClick);
	m_pFooterNode->removeBackground();
	this->addChild(m_pFooterNode);

	HeaderNode* pHeaderNode = HeaderNode::create();
	this->addChild(pHeaderNode);

	m_pSlideShow = ButtonManagerNode::create();
	m_pSlideShow->AllowSwipingBackground(true);
	m_pSlideShow->setPosition(Point(245.0f, 300.0f));

	ClipMaskNode* pClipMaskNode = ClipMaskNode::create();
	pClipMaskNode->setPosition(Point(75.0f, 155.0f));
	pClipMaskNode->setContentSize(Size(560.0f, 460.0f));
	pClipMaskNode->addChild(m_pSlideShow);
	pBackgroundFlashcard->addChild(pClipMaskNode);

	ChapterTable::getInstance()->refreshChapters();
	m_chapters = ChapterTable::getInstance()->getChaptersInfo();

	WordlMapConfig worlMapConfig = GameConfigManager::getInstance()->GetWordlMapConfig();
	
	int iCountIndex=0;
	for (int iIndex=0; iIndex<m_chapters.size(); iIndex++)
	{
		ChapterInfo chapterInfo = m_chapters[iIndex];
		if(chapterInfo.bIsUnlock)
		{
			int iTotalFlashcardUnlock = chapterInfo.iTotalFlashCardUnlock;
			if (iTotalFlashcardUnlock > 0)
			{
				Sprite* pBackgroundItem = Sprite::create("FlashCard/panel_flashcard_chapter.png");
				pBackgroundItem->setPosition(Point(0.0f, -iIndex*190));
				m_pSlideShow->addChild(pBackgroundItem);

				int iIndexChapter = worlMapConfig.m_WorlMapChapterConfigMap[chapterInfo.sChapterId];

				std::string sPath = worlMapConfig.m_WorlMapChapterConfigs[iIndexChapter].m_sPathData;
				sPath.append("/Flash-Card-icon.png");
				Sprite* pIconChapter = Sprite::create(sPath.c_str());

				ButtonNode* pButtonItem = ButtonNode::createButtonSprite(pIconChapter, CC_CALLBACK_1(FlashCardCollectionLayer::clickOpenFlashCard, this));
				pButtonItem->setTag(iIndex);
				pButtonItem->setPosition(Point(-140.0f, -15 -iIndex*190));
				m_pSlideShow->addButtonNode(pButtonItem);

				LabelBMFont* pLabelChapterName = LabelBMFont::create(worlMapConfig.m_WorlMapChapterConfigs[iIndexChapter].m_sChapterName.c_str(), "fonts/font_small_alert.fnt");
				pLabelChapterName->setPosition(Point(90.0f, 18 -iIndex*190));
				m_pSlideShow->addChild(pLabelChapterName);

				char sTotalFlashCard[10];
				sprintf(sTotalFlashCard, "(%d/%d)", iTotalFlashcardUnlock, chapterInfo.iTotalFlashCard);
				LabelTTF* pLabelTotalFlashCard = LabelTTF::create(sTotalFlashCard, "Arial", 25);
				pLabelTotalFlashCard->setColor(ccc3(0.0f, 0.0f, 0.0f));
				pLabelTotalFlashCard->setPosition(Point(90.0f, -18 -iIndex*190));
				m_pSlideShow->addChild(pLabelTotalFlashCard);

				if (iTotalFlashcardUnlock >= 0)
				{
					Sprite* pButtonPlayReviseGameImage = Sprite::create("AdvanceMode/btn-play-advance-mode.png");
					ButtonNode* pButtonPlayReviseGame = ButtonNode::createButtonSprite(pButtonPlayReviseGameImage, CC_CALLBACK_1(FlashCardCollectionLayer::clickPlayReviseGame, this));
					pButtonPlayReviseGame->setTag(iIndex);
					pButtonPlayReviseGame->setPosition(Point(235.0f, -iIndex*190));
					m_pSlideShow->addButtonNode(pButtonPlayReviseGame);
				}

				iCountIndex++;
				m_maxHeight = iCountIndex*190;
			}
		}
	}

	Breadcrumb::getInstance()->addSceneMode(SceneMode::kFlashCardCollection);

	this->setTouchEnabled(true);
	this->setTouchMode(Touch::DispatchMode::ONE_BY_ONE);

	m_pScrollManager = new ScrollManager();

	return true;
}