void LeaderBoardtNode::addItemToSlide(const int& iScore, const char* sName, const char* sFacebookId, const int& iRank, const int& iIndex) { Node* pNodeItem = Node::create(); Sprite* pLoadAvatar = Sprite::create("Target-End-Game/border_avatar.png"); pLoadAvatar->setPosition(Point(50.0f, 95.0f)); pNodeItem->addChild(pLoadAvatar); std::string urlAvatar = "https://graph.facebook.com/"; urlAvatar.append(sFacebookId); urlAvatar.append("/picture"); LoadingImagetNode* avatar = LoadingImagetNode::createLayout(urlAvatar.c_str()); avatar->setPosition(Point(50.0f, 95.0f)); pNodeItem->addChild(avatar); LabelBMFont *pLabelScore = LabelBMFont::create(formatNumber(iScore).getCString(), "fonts/font_small_alert.fnt"); pLabelScore->setAnchorPoint(Point(0.0f, 0.5f)); pLabelScore->setPosition(Point(57.0f, 8.0f)); pLabelScore->setScale(0.8); pNodeItem->addChild(pLabelScore); LabelTTF *pLabelName = LabelTTF::create(sName, "Arial", 20.0f); pLabelName->setColor(ccc3(0.0f, 0.0f, 0.0f)); //pLabelName->setScale(0.85f); pLabelName->setAnchorPoint(Point(0.0f, 0.5f)); pLabelName->setPosition(Point(57.0f, 45.0f)); pNodeItem->addChild(pLabelName); char sRank[10]; sprintf(sRank, "%d", iRank); LabelBMFont *pLabelRank = LabelBMFont::create(sRank, "fonts/font-bechic.fnt"); pLabelRank->setAnchorPoint(Point(0.0f, 0.5f)); pLabelRank->setPosition(Point(25.0f, 23.0f)); pNodeItem->addChild(pLabelRank); Sprite* pLineImage = Sprite::create("Target-End-Game/line.png"); pLineImage->setPosition(Point(160.0f, 55.0f)); pNodeItem->addChild(pLineImage); pNodeItem->setContentSize(Size(160.0f, 160.0f)); pNodeItem->setPosition(Point(-320.0f + iIndex*160, -100.0f)); pNodeItem->setTag(iIndex); m_pSlideShow->addChild(pNodeItem); Sprite* pIconAskLife = Sprite::create("Target-End-Game/btn_ask_life.png"); ButtonNode* pButtonAskLife = ButtonNode::createButtonSprite(pIconAskLife, CC_CALLBACK_1(LeaderBoardtNode::clickAskLife, this)); pButtonAskLife->setPosition(Point(-205.0f + iIndex*160, -5.0f)); m_pButtonManagerNode->addButtonNode(pButtonAskLife); }
bool EndGameCustomModeNode::init() { if (!Node::init()) { return false; } Sprite* pBackground = Sprite::create("AdvanceMode/background.png"); pBackground->setPosition(Point(320.0f, 485.0f)); this->addChild(pBackground); auto listener = EventListenerTouch::create(Touch::DispatchMode::ONE_BY_ONE); listener->setSwallowTouches(true); listener->onTouchBegan = [this](Touch* touch, Event* event) { return true; }; EventDispatcher::getInstance()->addEventListenerWithSceneGraphPriority(listener, pBackground); Sprite* pBackgroundPopUp = Sprite::create("AdvanceMode/panel-AM-short.png"); pBackgroundPopUp->setPosition(Point(320.0f, 595.0f)); this->addChild(pBackgroundPopUp); LabelBMFont *pLabelTitle = LabelBMFont::create("ADVANCE MODE", "fonts/font-bechic.fnt"); pLabelTitle->setAnchorPoint(Point(0.5f, 0.5f)); pLabelTitle->setPosition(Point(320.0f, 872.0f)); this->addChild(pLabelTitle); Sprite* pPanel = Sprite::create("AdvanceMode/panel-target-end-game.png"); pPanel->setPosition(Point(320.0f, 550.0f)); this->addChild(pPanel); /* Sprite* pIconEye1 = Sprite::create("AdvanceMode/eye-icon.png"); pIconEye1->setPosition(Point(500.0f, 550.0f)); this->addChild(pIconEye1); Sprite* pIconEye2 = Sprite::create("AdvanceMode/eye-icon.png"); pIconEye2->setPosition(Point(500.0f, 480.0f)); this->addChild(pIconEye2); */ m_csPackageInfo = CSPackageTable::getCSPackageInfo(m_sPackageId); if (m_csPackageInfo.iStage < m_iStage && m_iStage > 1) { Sprite* pNewRecord = Sprite::create("AdvanceMode/new-record.png"); pNewRecord->setPosition(Point(548.0f, 668.0f)); this->addChild(pNewRecord); m_csPackageInfo.iStage = m_iStage; } else if (m_csPackageInfo.iStage == 0) { m_csPackageInfo.iStage = m_iStage; } LabelBMFont *pLabelpackageName = LabelBMFont::create(m_csPackageInfo.sPackageName.c_str(), "fonts/font_title-popup.fnt"); pLabelpackageName->setAnchorPoint(Point(0.5f, 0.5f)); pLabelpackageName->setPosition(Point(320.0f, 780.0f)); this->addChild(pLabelpackageName); LabelTTF* pLabelTCreatedBy = LabelTTF::create(m_csPackageInfo.sCreatedBy.c_str(), "Arial", 28); pLabelTCreatedBy->setColor(ccc3(255.0f, 255.0f, 255.0f)); pLabelTCreatedBy->setPosition(Point(320.0f, 720.0f)); this->addChild(pLabelTCreatedBy); char sStage[20]; sprintf(sStage, "Stage %d", m_csPackageInfo.iStage); LabelBMFont *pLabelStage = LabelBMFont::create(sStage, "fonts/font_score.fnt", 310.0f); pLabelStage->setPosition(Point(320.0f, 630)); pLabelStage->setScale(1.4); this->addChild(pLabelStage); LabelBMFont *pLabelTotalWord = LabelBMFont::create("Total Words", "fonts/font_small_alert.fnt", 310.0f); pLabelTotalWord->setAnchorPoint(Point(0.0f, 0.5f)); pLabelTotalWord->setPosition(Point(122.0f, 550)); this->addChild(pLabelTotalWord); char sTotalWord[20]; sprintf(sTotalWord, "%d/%d", m_csPackageInfo.iTotalWordUnlock, m_csPackageInfo.iTotalWord); LabelBMFont *pLabelNumberTotalWord = LabelBMFont::create(sTotalWord, "fonts/font_score.fnt"); pLabelNumberTotalWord->setAnchorPoint(Point(1.0f, 0.5f)); pLabelNumberTotalWord->setPosition(Point(475.0f, 550)); pLabelNumberTotalWord->setScale(1.2); this->addChild(pLabelNumberTotalWord); LabelBMFont *pLabelWordNew = LabelBMFont::create("New words", "fonts/font_small_alert.fnt", 310.0f); pLabelWordNew->setAnchorPoint(Point(0.0f, 0.5f)); pLabelWordNew->setPosition(Point(122.0f, 480)); this->addChild(pLabelWordNew); char sTotalWordNew[10]; sprintf(sTotalWordNew, "%d", m_iWordNew); LabelBMFont *pLabelNumberWordNew = LabelBMFont::create(sTotalWordNew, "fonts/font_score.fnt"); pLabelNumberWordNew->setAnchorPoint(Point(1.0f, 0.5f)); pLabelNumberWordNew->setPosition(Point(475.0f, 480)); pLabelNumberWordNew->setScale(1.2); this->addChild(pLabelNumberWordNew); ButtonManagerNode* pButtonManagerNode = ButtonManagerNode::create(); this->addChild(pButtonManagerNode); Sprite* m_pButtonPlayImage = Sprite::create("AdvanceMode/btn_replay.png"); ButtonNode* pButtonPlay = ButtonNode::createButtonSprite(m_pButtonPlayImage, CC_CALLBACK_1(EndGameCustomModeNode::clickRetry, this)); pButtonPlay->setPosition(Point(320.0f, 345.0f)); pButtonManagerNode->addButtonNode(pButtonPlay); Sprite* m_pButtonCloseImage = Sprite::create("AdvanceMode/btn_close.png"); ButtonNode* pButtonClose = ButtonNode::createButtonSprite(m_pButtonCloseImage, CC_CALLBACK_1(EndGameCustomModeNode::clickClose, this)); pButtonClose->setPosition(Point(580.0f, 898.0f)); pButtonManagerNode->addButtonNode(pButtonClose); LeaderBoardAdvanceModeNode* pLeaderBoard = LeaderBoardAdvanceModeNode::createLayout(m_sPackageId); pLeaderBoard->setPosition(Point(320.0f, 114.0f)); this->addChild(pLeaderBoard); return true; }
bool LeaderBoardAdvanceModeNode::init() { if (!CustomNode::init()) { return false; } m_pSpriteBackground = Sprite::create("Target-End-Game/panel_high_score.png"); this->addChild(m_pSpriteBackground); this->setContentSize(m_pSpriteBackground->getContentSize()); LabelBMFont *pLabelHighScore = LabelBMFont::create("LEADER BOARD", "fonts/font_score.fnt"); pLabelHighScore->setPosition(Point(12.0f, 60.0f)); this->addChild(pLabelHighScore); m_pSlideShow = Node::create(); this->addChild(m_pSlideShow); m_pButtonManagerNode = ButtonManagerNode::create(); m_pButtonManagerNode->AllowSwipingBackground(true); Sprite* pImageNo1 = Sprite::create("Target-End-Game/btn_no1.png"); ButtonNode* pButtonNo1 = ButtonNode::createButtonSprite(pImageNo1, CC_CALLBACK_1(LeaderBoardAdvanceModeNode::clickNo1, this)); pButtonNo1->setPosition(Point(-230.0f, 60.0f)); m_pButtonManagerNode->addButtonNode(pButtonNo1); Sprite* pImageMe = Sprite::create("Target-End-Game/btn_me.png"); ButtonNode* pButtonMe = ButtonNode::createButtonSprite(pImageMe, CC_CALLBACK_1(LeaderBoardAdvanceModeNode::clickMe, this)); pButtonMe->setPosition(Point(230.0f, 60.0f)); m_pButtonManagerNode->addButtonNode(pButtonMe); this->addChild(m_pButtonManagerNode); m_pScrollManager = new ScrollManager(); m_iLeaderBoardCount = 0; m_fMinPositionLeft = 0; m_pointNo1 = m_pSlideShow->getPosition(); m_pointMe = m_pSlideShow->getPosition(); #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) FacebookManager::getInstance()->loadPlugin(); UserInfo userInfo = UserTable::getInstance()->getUserInfo(); if (userInfo.sFacebookId != "" && UserDefault::getInstance()->getIntegerForKey("IsLoginFacebook", 0) == 1 && FacebookManager::getInstance()->isLogined()) { IconLoadingNode* iconLoadingNode = IconLoadingNode::create(); iconLoadingNode->setTag(_TAG_ICON_LOADING_); iconLoadingNode->setPosition(0.0f, -30.0f); this->addChild(iconLoadingNode, _TAG_ICON_LOADING_); UserService::getInstance()->addCallBackList(this); m_iConnectServer = UserDefault::getInstance()->getIntegerForKey("NumberConnectServer", 0); m_iConnectServer++; UserDefault::getInstance()->setIntegerForKey("NumberConnectServer", m_iConnectServer); UserService::getInstance()->getLeaderBoardAdvanceMode(m_sPackageId, m_iConnectServer); } #endif /* IconLoadingNode* iconLoadingNode = IconLoadingNode::create(); iconLoadingNode->setTag(_TAG_ICON_LOADING_); iconLoadingNode->setPosition(0.0f, -30.0f); this->addChild(iconLoadingNode, _TAG_ICON_LOADING_); UserService::getInstance()->addCallBackList(this); m_iConnectServer = UserDefault::getInstance()->getIntegerForKey("NumberConnectServer", 0); m_iConnectServer++; UserDefault::getInstance()->setIntegerForKey("NumberConnectServer", m_iConnectServer); UserService::getInstance()->getLeaderBoardAdvanceMode(m_sPackageId, m_iConnectServer); */ return true; }
void LeaderBoardAdvanceModeNode::resultHttpRequestCompleted(cs::JsonDictionary* pJsonDict, std::string sKey) { this->removeChildByTag(_TAG_ICON_LOADING_); if (pJsonDict != NULL) { UserInfo userInfo = UserTable::getInstance()->getUserInfo(); CSPackageInfo csPackageInfo = CSPackageTable::getCSPackageInfo(m_sPackageId); String sTag = "LeaderBoardAdvanceMode"; sTag.appendWithFormat("_%d", m_iConnectServer); if (sKey == sTag.getCString()) { cs::JsonDictionary* jsonData = pJsonDict->getSubDictionary("data"); if (jsonData != NULL) { if (jsonData->getItemBoolvalue("result", false)) { cs::JsonDictionary* pJsonList = jsonData->getSubDictionary("list"); if (pJsonList != NULL) { int iStageMaxMe = csPackageInfo.iStage; cs::JsonDictionary* pJsonMe = pJsonList->getSubDictionary("Me"); if (pJsonMe != NULL) { iStageMaxMe = pJsonMe->getItemIntValue("HighNumberStage", 0); if (iStageMaxMe < csPackageInfo.iStage) { iStageMaxMe = csPackageInfo.iStage; } } m_iLeaderBoardCount = pJsonList->getArrayItemCount("Friends"); // find index of me int iRankMe = 1; for(int iIndex=0; iIndex < m_iLeaderBoardCount; iIndex++) { cs::JsonDictionary* pJsonItem = pJsonList->getSubItemFromArray("Friends", iIndex); int iStage = pJsonItem->getItemIntValue("HighNumberStage", 0); if (iStage > iStageMaxMe) iRankMe++; else break; } // Add me to slide this->addItemToSlide(iStageMaxMe, "Me", userInfo.sFacebookId.c_str(), iRankMe); m_pointMe.x = -(iRankMe-1)*160; // Add friends to slide int iCountRank = 0; for (int iIndex=0; iIndex<m_iLeaderBoardCount; iIndex++) { iCountRank++; if (iCountRank == iRankMe) iCountRank++; cs::JsonDictionary* pJsonItem = pJsonList->getSubItemFromArray("Friends", iIndex); this->parseJsonToLeadeBoard(pJsonItem, iCountRank); } m_iLeaderBoardCount = m_iLeaderBoardCount + 1 + 1; m_fMinPositionLeft = -((m_iLeaderBoardCount-4)*160.0f); Node* pInviteFriendsNode = Node::create(); Sprite* pButtonInviteImage = Sprite::create("Target-End-Game/btn-add-friend-small.png"); LabelTTF* pLabelTCreatedBy = LabelTTF::create("Invite Friends", "Arial", 22); pLabelTCreatedBy->setColor(ccc3(255.0f, 255.0f, 255.0f)); pLabelTCreatedBy->setPosition(Point(55.0f, -10.0f)); pButtonInviteImage->addChild(pLabelTCreatedBy); ButtonNode* pButtonInvite = ButtonNode::createButtonSprite(pButtonInviteImage, CC_CALLBACK_1(LeaderBoardAdvanceModeNode::clickInviteFriends, this)); pButtonInvite->setPosition(Point(80.0f, 70.0f)); ButtonManagerNode* pButtonManager = ButtonManagerNode::create(); pButtonManager->addButtonNode(pButtonInvite); pInviteFriendsNode->addChild(pButtonManager); pInviteFriendsNode->setContentSize(Size(160.0f, 160.0f)); pInviteFriendsNode->setPosition(Point(-320.0f + (m_iLeaderBoardCount-1)*160, -100.0f)); m_pSlideShow->addChild(pInviteFriendsNode); } } else { } } } } }
bool EndGameNode::initWin() { if (!Node::init()) { return false; } LevelConfig* pLevelConfig = &GameConfigManager::getInstance()->GetLevelConfig(m_sChapterId, m_iCurrentLevel); m_iTotalBonusQuest = pLevelConfig->m_BonusQuestConfig.m_iBonusQuestCount; LayerColor* pBackground = LayerColor::create(ccc4(7, 25, 44, 150)); pBackground->setContentSize(CCSizeMake(640.0f, 960.0f)); auto listener = EventListenerTouch::create(Touch::DispatchMode::ONE_BY_ONE); listener->setSwallowTouches(true); listener->onTouchBegan = [](Touch* touch, Event* event) { return true; }; EventDispatcher::getInstance()->addEventListenerWithSceneGraphPriority(listener, pBackground); this->addChild(pBackground); this->setContentSize(pBackground->getContentSize()); //m_pSpriteBatchNode = SpriteBatchNode::create("Target-End-Game/TargetEndgame.pvr.ccz"); //SpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("Target-End-Game/TargetEndgame.plist"); //this->addChild(m_pSpriteBatchNode); Sprite* pBackgroundBoard = Sprite::create("Target-End-Game/panel-level_popup.png"); pBackgroundBoard->setPosition(Point(320.0f, 610.0f)); this->addChild(pBackgroundBoard); m_pStarAndBonusQuestNode = Node::create(); this->addChild(m_pStarAndBonusQuestNode); this->generateLayoutStartAndBonusQuest(); Sprite* pCompletedImage = Sprite::create("Target-End-Game/text_level_completed.png"); pCompletedImage->setPosition(Point(320.0f, 654.0f)); this->addChild(pCompletedImage); FlashCardNode* pFlashCard = FlashCardNode::createLayout(m_mainWord); pFlashCard->setPosition(70.0f, 200.0f); pFlashCard->setScale(0.52f); this->addChild(pFlashCard); char sLevel[20]; int iCalLevel = GameConfigManager::getInstance()->CountLevelOfPreviousChapters(m_sChapterId); sprintf(sLevel, "Level %d", m_iCurrentLevel + iCalLevel); LabelBMFont *pLabelLevel = LabelBMFont::create(sLevel, "fonts/font-bechic.fnt"); pLabelLevel->setAnchorPoint(Point(0.5f, 0.5f)); pLabelLevel->setPosition(Point(320.0f, 870.0f)); this->addChild(pLabelLevel); LabelBMFont *pLabelScore = LabelBMFont::create("SCORE:", "fonts/font_score.fnt"); pLabelScore->setAnchorPoint(Point(0.5f, 0.5f)); pLabelScore->setPosition(Point(474.0f, 525.0f)); this->addChild(pLabelScore); LabelBMFont *pLabelNumScore = LabelBMFont::create(formatNumber(m_iScore).getCString(), "fonts/font_score.fnt"); pLabelNumScore->setAnchorPoint(Point(0.5f, 0.5f)); pLabelNumScore->setPosition(Point(474.0f, 480.0f)); pLabelNumScore->setScale(1.4f); this->addChild(pLabelNumScore); Sprite* pButtonNextGameSprite = Sprite::create("Target-End-Game/btn_next.png"); ButtonNode* buttonNextNode = ButtonNode::createButtonSprite(pButtonNextGameSprite, CC_CALLBACK_1(EndGameNode::menuNextLevelCallBack, this)); buttonNextNode->setPosition(Point(425.0f, 279.0f)); Sprite* pButtonReplayGameSprite = Sprite::create("Target-End-Game/btn_replay.png"); ButtonNode* buttonReplayNode = ButtonNode::createButtonSprite(pButtonReplayGameSprite, CC_CALLBACK_1(EndGameNode::menuRetryLevelWinCallBack, this)); buttonReplayNode->setPosition(Point(225.0f, 279.0f)); Sprite* pButtonCloseSprite = Sprite::create("Target-End-Game/btn_close.png"); ButtonNode* buttonCloseNode = ButtonNode::createButtonSprite(pButtonCloseSprite, CC_CALLBACK_1(EndGameNode::menuCloseWinCallBack, this)); buttonCloseNode->setPosition(Point(572.0f, 894.0f)); ButtonManagerNode* pButtonManagerNode = ButtonManagerNode::create(); pButtonManagerNode->addButtonNode(buttonNextNode); pButtonManagerNode->addButtonNode(buttonCloseNode); pButtonManagerNode->addButtonNode(buttonReplayNode); this->addChild(pButtonManagerNode); m_levelInfo = LevelTable::getInstance()->getLevel(m_sChapterId, m_iCurrentLevel); m_chapterInfo = ChapterTable::getInstance()->getChapterInfo(m_sChapterId); if (m_levelInfo.bIsUnlock == false) { m_chapterInfo.iTotalLevelUnlock++; UserInfo userInfo = UserTable::getInstance()->getUserInfo(); userInfo.sCurrentChapterId = m_levelInfo.sChapterId; userInfo.iCurrentLevel = m_levelInfo.iLevel + 1; // Unlock chapter WordlMapConfig worldMapConfig = GameConfigManager::getInstance()->GetWordlMapConfig(); int iIndexCurrentChapter = worldMapConfig.m_WorlMapChapterConfigMap[m_levelInfo.sChapterId]; WordlMapConfig::WordMapChapterConfig worldMapChapterConfig = worldMapConfig.m_WorlMapChapterConfigs[iIndexCurrentChapter]; if (m_iCurrentLevel >= worldMapChapterConfig.m_iTotalevel) { //userInfo.iCurrentLevel = worldMapChapterConfig.m_iTotalevel; // Create data for new chapter std::string sNextChapterID; if ( GameConfigManager::getInstance()->GetNextChapterID(worldMapChapterConfig.m_sChapterId, sNextChapterID)) { InitDatabase::getInstance()->createDataChapterAndLevel(sNextChapterID); userInfo.sCurrentChapterId = sNextChapterID; userInfo.iCurrentLevel = 1; UserDefault::getInstance()->setStringForKey("ChapterPlayGame", userInfo.sCurrentChapterId); } else // the last chapter is finished so game is end now!!!! { } } UserTable::getInstance()->updateUser(userInfo); } m_levelInfo.bIsUnlock = true; m_levelInfo.iTotalBonusQuest = m_iTotalBonusQuest; if (m_levelInfo.iScore < m_iScore) { m_levelInfo.iScore = m_iScore; } if(m_levelInfo.iBonusQuest < m_iBonusQuestCompleted) { m_levelInfo.iBonusQuest = m_iBonusQuestCompleted; } if(m_levelInfo.iStar < m_iYellowStar) { m_chapterInfo.iTotalStar += m_iYellowStar - m_levelInfo.iStar; m_levelInfo.iStar = m_iYellowStar; } // Update Word for chapter const std::string sWordId = GameWordManager::getInstance()->GetWordIdFromWord(m_mainWord); WordInfo wordInfo = WordTable::getInstance()->getWordInfoOnChapter(m_levelInfo.sChapterId, sWordId); wordInfo.iCountCollected++; LevelTable::getInstance()->updateLevel(m_levelInfo); WordTable::getInstance()->updateWord(wordInfo); ChapterTable::getInstance()->updateChapter(m_chapterInfo); m_iCountYellowStar = 0; m_iCountBonusQuest = 0; this->sequenceUpdateStar(); LeaderBoardtNode* pLeaderBoard = LeaderBoardtNode::createLayout(m_iCurrentLevel, m_sChapterId); pLeaderBoard->setPosition(Point(320.0f, 114.0f)); this->addChild(pLeaderBoard); auto actionupdateDatabaseAndSync = CallFunc::create(this, callfunc_selector(EndGameNode::updateDatabaseAndSync)); this->runAction(Sequence::create(DelayTime::create(0.01f), actionupdateDatabaseAndSync, NULL)); return true; }
bool EndGameNode::initLose() { if (!Node::init()) { return false; } LayerColor* pBackground = LayerColor::create(ccc4(7, 25, 44, 150)); pBackground->setContentSize(CCSizeMake(640.0f, 960.0f)); auto listener = EventListenerTouch::create(Touch::DispatchMode::ONE_BY_ONE); listener->setSwallowTouches(true); listener->onTouchBegan = [](Touch* touch, Event* event) { return true; }; EventDispatcher::getInstance()->addEventListenerWithSceneGraphPriority(listener, pBackground); this->addChild(pBackground); this->setContentSize(pBackground->getContentSize()); //m_pSpriteBatchNode = SpriteBatchNode::create("Target-End-Game/TargetEndgame.pvr.ccz"); //SpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("Target-End-Game/TargetEndgame.plist"); //this->addChild(m_pSpriteBatchNode); Sprite* pBackgroundBoard = Sprite::create("Target-End-Game/panel-level_popup.png"); pBackgroundBoard->setPosition(Point(320.0f, 610.0f)); this->addChild(pBackgroundBoard); Sprite* pLevelFailImage3 = Sprite::create("Target-End-Game/text_level_fail.png"); pLevelFailImage3->setPosition(Point(320.0f, 750.0f)); this->addChild(pLevelFailImage3); Sprite* pIconBoosterLock1 = Sprite::create("Target-End-Game/lock-icon-powerup.png"); pIconBoosterLock1->setPosition(Point(220.0f, 415.0f)); this->addChild(pIconBoosterLock1); Sprite* pIconBoosterLock2 = Sprite::create("Target-End-Game/lock-icon-powerup.png"); pIconBoosterLock2->setPosition(Point(320.0f, 415.0f)); this->addChild(pIconBoosterLock2); Sprite* pIconBoosterLock3 = Sprite::create("Target-End-Game/lock-icon-powerup.png"); pIconBoosterLock3->setPosition(Point(420.0f, 415.0f)); this->addChild(pIconBoosterLock3); FlashCardNode* pFlashCard = FlashCardNode::createLayout(m_mainWord); pFlashCard->setPosition(70.0f, 285.0f); pFlashCard->setScale(0.52f); this->addChild(pFlashCard); char sLevel[20]; int iCalLevel = GameConfigManager::getInstance()->CountLevelOfPreviousChapters(m_sChapterId); sprintf(sLevel, "Level %d", m_iCurrentLevel + iCalLevel); LabelBMFont *pLabelLevel = LabelBMFont::create(sLevel, "fonts/font-bechic.fnt"); pLabelLevel->setAnchorPoint(Point(0.5f, 0.5f)); pLabelLevel->setPosition(Point(320.0f, 870.0f)); this->addChild(pLabelLevel); LabelBMFont *pLabelScore = LabelBMFont::create("SCORE:", "fonts/font_score.fnt"); pLabelScore->setAnchorPoint(Point(0.5f, 0.5f)); pLabelScore->setPosition(Point(474.0f, 630.0f)); this->addChild(pLabelScore); LabelBMFont *pLabelNumScore = LabelBMFont::create(formatNumber(m_iScore).getCString(), "fonts/font_score.fnt"); pLabelNumScore->setAnchorPoint(Point(0.5f, 0.5f)); pLabelNumScore->setPosition(Point(474.0f, 585.0f)); pLabelNumScore->setScale(1.4f); this->addChild(pLabelNumScore); LeaderBoardtNode* pLeaderBoard = LeaderBoardtNode::createLayout(m_iCurrentLevel, m_sChapterId); pLeaderBoard->setPosition(Point(320.0f, 114.0f)); this->addChild(pLeaderBoard); Sprite* pButtonPlayGameSprite = Sprite::create("Target-End-Game/btn_replay.png"); ButtonNode* buttonPlayNode = ButtonNode::createButtonSprite(pButtonPlayGameSprite, CC_CALLBACK_1(EndGameNode::menuRetryLevelLoseCallBack, this)); buttonPlayNode->setPosition(Point(320.0f, 279.0f)); Sprite* pButtonCloseSprite = Sprite::create("Target-End-Game/btn_close.png"); ButtonNode* buttonCloseNode = ButtonNode::createButtonSprite(pButtonCloseSprite, CC_CALLBACK_1(EndGameNode::menuCloseLoseCallBack, this)); buttonCloseNode->setPosition(Point(572.0f, 894.0f)); ButtonManagerNode* pButtonManagerNode = ButtonManagerNode::create(); pButtonManagerNode->addButtonNode(buttonPlayNode); pButtonManagerNode->addButtonNode(buttonCloseNode); this->addChild(pButtonManagerNode); return true; }
void LeaderBoardtNode::resultHttpRequestCompleted(cs::JsonDictionary* pJsonDict, std::string sKey) { this->removeChildByTag(_TAG_ICON_LOADING_); if (pJsonDict != NULL) { LevelInfo levelInfo = LevelTable::getInstance()->getLevel(m_sChapterId, m_iLevel); UserInfo userInfo = UserTable::getInstance()->getUserInfo(); String sTag = "LeaderBoardLevel"; sTag.appendWithFormat("_%d", m_iConnectServer); if (sKey == sTag.getCString()) { cs::JsonDictionary* jsonData = pJsonDict->getSubDictionary("data"); if (jsonData != NULL) { if (jsonData->getItemBoolvalue("result", false)) { m_iLeaderBoardCount = jsonData->getArrayItemCount("list"); if (levelInfo.bIsUnlock) { // find index of me int iRank = 1; for(int iIndex=0; iIndex < m_iLeaderBoardCount; iIndex++) { cs::JsonDictionary* pJsonItem = jsonData->getSubItemFromArray("list", iIndex); int iScore = pJsonItem->getItemIntValue("Score", 0); if (iScore > levelInfo.iScore) iRank++; else break; } if (iRank == 1) { this->addItemToSlide(levelInfo.iScore, "Me", userInfo.sFacebookId.c_str(), iRank, 0); if (m_iLeaderBoardCount > 5) m_iLeaderBoardCount = 5; for(int iIndex=0; iIndex < m_iLeaderBoardCount; iIndex++) { iRank++; cs::JsonDictionary* pJsonItem = jsonData->getSubItemFromArray("list", iIndex); this->parseJsonToLeadeBoard(pJsonItem, iRank, iIndex+1); } } else { if (iRank > m_iLeaderBoardCount) { if (iRank >= 6) { this->addItemToSlide(levelInfo.iScore, "Me", userInfo.sFacebookId.c_str(), iRank, 5); cs::JsonDictionary* pJsonItemLeft1 = jsonData->getSubItemFromArray("list", iRank-2); this->parseJsonToLeadeBoard(pJsonItemLeft1, iRank-1, 4); cs::JsonDictionary* pJsonItemLeft2 = jsonData->getSubItemFromArray("list", iRank-3); this->parseJsonToLeadeBoard(pJsonItemLeft2, iRank-2, 3); } else { this->addItemToSlide(levelInfo.iScore, "Me", userInfo.sFacebookId.c_str(), iRank, iRank-1); cs::JsonDictionary* pJsonItemLeft1 = jsonData->getSubItemFromArray("list", iRank-2); this->parseJsonToLeadeBoard(pJsonItemLeft1, iRank-1, iRank-2); cs::JsonDictionary* pJsonItemLeft2 = jsonData->getSubItemFromArray("list", iRank-3); this->parseJsonToLeadeBoard(pJsonItemLeft2, iRank-2, iRank-3); } } else { if (iRank >= 6) { this->addItemToSlide(levelInfo.iScore, "Me", userInfo.sFacebookId.c_str(), iRank, 4); cs::JsonDictionary* pJsonItemRight = jsonData->getSubItemFromArray("list", iRank-1); this->parseJsonToLeadeBoard(pJsonItemRight, iRank+1, 5); cs::JsonDictionary* pJsonItemLeft = jsonData->getSubItemFromArray("list", iRank-2); this->parseJsonToLeadeBoard(pJsonItemLeft, iRank-1, 3); } else { this->addItemToSlide(levelInfo.iScore, "Me", userInfo.sFacebookId.c_str(), iRank, iRank-1); cs::JsonDictionary* pJsonItemRight = jsonData->getSubItemFromArray("list", iRank-1); this->parseJsonToLeadeBoard(pJsonItemRight, iRank+1, iRank); cs::JsonDictionary* pJsonItemLeft = jsonData->getSubItemFromArray("list", iRank-2); this->parseJsonToLeadeBoard(pJsonItemLeft, iRank-1, iRank-2); } } int iCount = 0; for (int iIndex=0; iIndex<m_iLeaderBoardCount; iIndex++) { if(iCount > 2) break; if (iIndex < iRank-2) { iCount++; cs::JsonDictionary* pJsonItem = jsonData->getSubItemFromArray("list", iIndex); this->parseJsonToLeadeBoard(pJsonItem, iIndex+1, iIndex); } else if (iIndex > iRank-1) { iCount++; cs::JsonDictionary* pJsonItem = jsonData->getSubItemFromArray("list", iIndex); this->parseJsonToLeadeBoard(pJsonItem, iIndex+2, iIndex+1); } } } m_iLeaderBoardCount = m_iLeaderBoardCount + 1; if (m_iLeaderBoardCount > 6 ) m_iLeaderBoardCount = 6; } else { if (m_iLeaderBoardCount > 6) m_iLeaderBoardCount = 6; for(int iIndex=0; iIndex < m_iLeaderBoardCount; iIndex++) { cs::JsonDictionary* pJsonItem = jsonData->getSubItemFromArray("list", iIndex); this->parseJsonToLeadeBoard(pJsonItem, iIndex+1, iIndex); } } m_iLeaderBoardCount = m_iLeaderBoardCount + 1; m_fMinPositionLeft = -((m_iLeaderBoardCount-4)*160.0f); Node* pInviteFriendsNode = Node::create(); Sprite* pButtonInviteImage = Sprite::create("Target-End-Game/btn-add-friend-small.png"); LabelTTF* pLabelTCreatedBy = LabelTTF::create("Invite Friends", "Arial", 22); pLabelTCreatedBy->setColor(ccc3(255.0f, 255.0f, 255.0f)); pLabelTCreatedBy->setPosition(Point(55.0f, -10.0f)); pButtonInviteImage->addChild(pLabelTCreatedBy); ButtonNode* pButtonInvite = ButtonNode::createButtonSprite(pButtonInviteImage, CC_CALLBACK_1(LeaderBoardtNode::clickInviteFriends, this)); pButtonInvite->setPosition(Point(80.0f, 70.0f)); ButtonManagerNode* pButtonManager = ButtonManagerNode::create(); pButtonManager->addButtonNode(pButtonInvite); pInviteFriendsNode->addChild(pButtonManager); pInviteFriendsNode->setContentSize(Size(160.0f, 160.0f)); pInviteFriendsNode->setPosition(Point(-320.0f + (m_iLeaderBoardCount-1)*160, -100.0f)); m_pSlideShow->addChild(pInviteFriendsNode); } else { } } } } }
void AdvanceModePopularPackagesLayer::resultHttpRequestCompleted(cs::JsonDictionary* pJsonDict, std::string sKey) { this->removeChildByTag(_TAG_ICON_LOADING_); String sTag = "GetPackagePopular"; sTag.appendWithFormat("_%d", m_iConnectServer); if (sKey == sTag.getCString()) { if (pJsonDict != NULL) { cs::JsonDictionary* jsonData = pJsonDict->getSubDictionary("data"); if(jsonData != NULL) { if (jsonData->getItemBoolvalue("result", false)) { m_iTotalPackage = jsonData->getArrayItemCount("list"); m_maxHeight = m_iTotalPackage*120.0f; for(int iIndex=0; iIndex < m_iTotalPackage; iIndex++) { cs::JsonDictionary* pJsonItem = jsonData->getSubItemFromArray("list", iIndex); CSPackageInfo csPackageInfo; csPackageInfo.sPackageName = pJsonItem->getItemStringValue("WordListName"); csPackageInfo.sPackageCode = pJsonItem->getItemStringValue("PackageCode"); csPackageInfo.sCreatedBy = pJsonItem->getItemStringValue("Author"); csPackageInfo.iTotalWord = pJsonItem->getItemIntValue("TotalWords", 0); csPackageInfo.iTotalWordUnlock = 0; m_csPackageInfos.push_back(csPackageInfo); LabelBMFont *pLabelPackageName = LabelBMFont::create(csPackageInfo.sPackageName.c_str(), "fonts/font_small_alert.fnt", 310.0f); pLabelPackageName->setAnchorPoint(Point(0.0f, 0.5f)); pLabelPackageName->setPosition(Point(0.0f, -iIndex*120 - 10)); m_pSlideShow->addChild(pLabelPackageName); LabelTTF* pLabelTCreatedBy = LabelTTF::create(csPackageInfo.sCreatedBy.c_str(), "Arial", 28, Size(310.0f, 30.0f), TextHAlignment::LEFT, TextVAlignment::TOP); pLabelTCreatedBy->setColor(ccc3(255.0f, 255.0f, 255.0f)); pLabelTCreatedBy->setAnchorPoint(Point(0.0f, 0.5f)); pLabelTCreatedBy->setPosition(Point(0.0f, -iIndex*120 - 55)); m_pSlideShow->addChild(pLabelTCreatedBy); LabelBMFont *pLabelPackageCode = LabelBMFont::create(csPackageInfo.sPackageCode.c_str(), "fonts/font_score.fnt"); pLabelPackageCode->setAnchorPoint(Point(1.0f, 0.5f)); pLabelPackageCode->setPosition(Point(440.0f, -iIndex*120 - 10)); m_pSlideShow->addChild(pLabelPackageCode); char sTotalWord[20]; sprintf(sTotalWord, "%d Words", csPackageInfo.iTotalWord); LabelTTF* pLabelTotalWord = LabelTTF::create(sTotalWord, "Arial", 28); pLabelTotalWord->setColor(ccc3(255.0f, 255.0f, 255.0f)); pLabelTotalWord->setAnchorPoint(Point(1.0f, 0.5f)); pLabelTotalWord->setPosition(Point(420.0f, -iIndex*120 - 55)); m_pSlideShow->addChild(pLabelTotalWord); Sprite* pButtonPlayPackageImage = Sprite::create("AdvanceMode/download-icon.png"); ButtonNode* pButtonPlayPackage = ButtonNode::createButtonSprite(pButtonPlayPackageImage, CC_CALLBACK_1(AdvanceModePopularPackagesLayer::clickDownloadPackage, this)); pButtonPlayPackage->setTag(iIndex); pButtonPlayPackage->setPosition(Point(460.0f, -iIndex*120 - 35)); m_pSlideShow->addButtonNode(pButtonPlayPackage); Sprite* pLineImage = Sprite::create("AdvanceMode/line.png"); pLineImage->setPosition(Point(245.0f, -iIndex*120 -90.0f)); m_pSlideShow->addChild(pLineImage, 5); } } } } } }
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; }