void HelloWorld::showRestartMenu()
{
    Size winSize = Director::getInstance()->getWinSize();

    const char *message;
    if (_won)
    {
        message = "You win!";
    }
    else
    {
        message = "You lose!";
    }

    LabelBMFont *label = LabelBMFont::create(message, "Arial.fnt");
    label->setScale(0.1f);
    label->setPosition(winSize.width / 2, winSize.height * 0.6f);
    this->addChild(label);

    LabelBMFont *restartLabel = LabelBMFont::create("Restart", "Arial.fnt");
    MenuItemLabel *restartItem = MenuItemLabel::create(restartLabel, [](Object *sender){
        Director::getInstance()->replaceScene(TransitionZoomFlipX::create(0.5f, HelloWorld::createScene()));
    });
    restartItem->setScale(0.1f);
    restartItem->setPosition(winSize.width / 2, winSize.height * 0.4f);

    Menu *menu = Menu::createWithItem(restartItem);
    menu->setPosition(Point::ZERO);
    this->addChild(menu);

    restartItem->runAction(ScaleTo::create(0.5f, 1.0f));
    label->runAction(ScaleTo::create(0.5f, 1.0f));
}
void HelloWorld::endScene(EndReason endReason) {
	if (_gameOver)
		return;
	_gameOver = true;

	//存储分数
	setHighestHistorySorce();
	gScore = 0;

	auto winSize = Director::getInstance()->getWinSize();
	char message[10] = "You Win";
	if (endReason == KENDREASONLOSE)
		strcpy(message, "You Lose");
	LabelBMFont * label;
	label = LabelBMFont::create(message,"fonts/Arial.fnt");
	label->setScale(0.1);
	label->setPosition(Point(winSize.width / 2, winSize.height*0.6));
	this->addChild(label);

	LabelBMFont * restartLabel;
	restartLabel = LabelBMFont::create("Restart", "fonts/Arial.fnt");
	auto *restartItem = MenuItemLabel::create(restartLabel,CC_CALLBACK_1(HelloWorld::restartTapped,this));
	restartItem->setScale(0.1);
	restartItem->setPosition(Point(winSize.width / 2, winSize.height*0.4));

	Menu *menu = Menu::create(restartItem, NULL);
	menu->setPosition(Point::ZERO);
	this->addChild(menu);

	// clear label and menu
	restartItem->runAction(ScaleTo::create(0.5, 1.0));
	label->runAction(ScaleTo::create(0.5, 1.0));
	// Terminate update callback
	this->unscheduleUpdate();
}
// on "init" you need to initialize your instance
bool OptionsMenu::init()
{
    Size visibleSize = CCDirector::sharedDirector()->getVisibleSize();
    Vec2 origin = CCDirector::sharedDirector()->getVisibleOrigin();

    scrollingBgLayer = new ScrollingBgLayer(3.0);
    this->addChild(scrollingBgLayer);


    LabelBMFont *nameLabel = LabelBMFont::create("Options Menu","PixelFont.fnt");
    nameLabel->setPosition(visibleSize.width/2, visibleSize.height * 0.8);
    this->addChild(nameLabel);

    MenuItemImage *presetItem = MenuItemImage::create("_bookgame_UI__resume.png",
                                "_bookgame_UI__resume.png",
                                CC_CALLBACK_1(OptionsMenu::reset, this));
    presetItem->setPosition(ccp(visibleSize.width/2 - visibleSize.width * 0.125,  visibleSize.height * 0.5));


    MenuItemImage *pmainMenuItem = MenuItemImage::create("_bookgame_UI_mainmenu.png",
                                   "_bookgame_UI_mainmenu.png",
                                   CC_CALLBACK_1(OptionsMenu::mainMenu, this));
    pmainMenuItem->setPosition(Vec2(visibleSize.width/2 + visibleSize.width * 0.125, visibleSize.height * 0.5 ));



    //sound onoff items
    soundOnItem = MenuItemImage::create("_bookgame_UI_soundON.png","_bookgame_UI_soundON.png", this,NULL);
    soundOffItem = MenuItemImage::create("_bookgame_UI_soundOFF.png","_bookgame_UI_soundOFF.png", this,NULL);

    bool isPaused = CCUserDefault::sharedUserDefault()->getBoolForKey("tinyBazooka_kSoundPausedKey");

    MenuItemToggle* soundToggleItem;
    if(isPaused == false) {
        soundToggleItem = MenuItemToggle::createWithTarget(this,menu_selector(OptionsMenu::SoundOnOff),
                          soundOnItem, soundOffItem,NULL);
    } else {
        soundToggleItem = MenuItemToggle::createWithTarget(this,menu_selector(OptionsMenu::SoundOnOff),
                          soundOffItem, soundOnItem,NULL);
    }

    soundToggleItem->setPosition(ccp(visibleSize.width* 0.5, visibleSize.height * 0.5 ));




    // create menu, it's an autorelease object
    Menu* pMenu = Menu::create(pmainMenuItem, presetItem,soundToggleItem, NULL);
    pMenu->setPosition(Vec2::ZERO);
    this->addChild(pMenu, 10);

    this->scheduleUpdate();

    return true;

}
//LabelBMFont - Creation & Init
LabelBMFont *LabelBMFont::create(const std::string& str, const std::string& fntFile, float width /* = 0 */, TextHAlignment alignment /* = TextHAlignment::LEFT */,const Vec2& imageOffset /* = Vec2::ZERO */)
{
    LabelBMFont *ret = new (std::nothrow) LabelBMFont();
    if(ret && ret->initWithString(str, fntFile, width, alignment,imageOffset))
    {
        ret->autorelease();
        return ret;
    }
    CC_SAFE_DELETE(ret);
    return nullptr;
}
NS_CC_BEGIN

LabelBMFont * LabelBMFont::create()
{
    LabelBMFont * pRet = new (std::nothrow) LabelBMFont();
    if (pRet)
    {
        pRet->autorelease();
        return pRet;
    }
    CC_SAFE_DELETE(pRet);
    return nullptr;
}
NS_CC_BEGIN

LabelBMFont * LabelBMFont::create()
{
    LabelBMFont * pRet = new LabelBMFont();
    if (pRet && pRet->init())
    {
        pRet->autorelease();
        return pRet;
    }
    CC_SAFE_DELETE(pRet);
    return nullptr;
}
Exemple #7
0
void LayerGameMain::updateBigBoomCount(int bigBoomCount)
{
	String strBoomCount;
	Sprite * norBoom = Sprite::createWithSpriteFrameName("bomb.png");
	Sprite * selBoom = Sprite::createWithSpriteFrameName("bomb.png");
	if (bigBoomCount < 0)
	{
		return;
	}
	else if (bigBoomCount == 0)
	{
		if (this->getChildByTag(TAG_BIGBOOM))
		{
			this->removeChildByTag(TAG_BIGBOOM,true);
		}
		if (this->getChildByTag(TAG_BIGBOOMCOUNT))
		{
			this->removeChildByTag(TAG_BIGBOOMCOUNT,true);
		}
	}
	else if (bigBoomCount == 1)
	{
		if ( !(this->getChildByTag(TAG_BIGBOOM)) )
		{
			MenuItemSprite * boomItem = MenuItemSprite::create(norBoom,
															   selBoom,
															   CC_CALLBACK_1(LayerGameMain::boomMenuCallback,this));
			boomItem->setPosition(norBoom->getContentSize().width/2,norBoom->getContentSize().height/2);
			Menu * boomMenu = Menu::create(boomItem,nullptr);
			boomMenu->setPosition(Point::ZERO);
			this->addChild(boomMenu,0,TAG_BIGBOOM);
		}
		if ( !(this->getChildByTag(TAG_BIGBOOMCOUNT)) )
		{
			strBoomCount.initWithFormat("X %d",bigBoomCount);
			LabelBMFont * labelBoomCount = LabelBMFont::create(strBoomCount.getCString(),"font/font.fnt");
			labelBoomCount->setAnchorPoint(Point::ANCHOR_MIDDLE_LEFT);
			labelBoomCount->setPosition(Point(norBoom->getContentSize().width,norBoom->getContentSize().height - 30));
			this->addChild(labelBoomCount,0,TAG_BIGBOOMCOUNT);
		}
	}
	else if (bigBoomCount > 1 && bigBoomCount < MAX_BIGBOOM_COUNT)
	{
		strBoomCount.initWithFormat("X %d",bigBoomCount);
		LabelBMFont * labelCount = (LabelBMFont *)this->getChildByTag(TAG_BIGBOOMCOUNT);
		labelCount->setString(strBoomCount.getCString());
	}
}
Exemple #8
0
void LayerGameMain::boomMenuCallback(cocos2d::Ref * ref)
{
	_bigBoomCount--;
	String strBoomCount;
	strBoomCount.initWithFormat("X %d",_bigBoomCount);
	LabelBMFont * labelCount = (LabelBMFont *)this->getChildByTag(TAG_BIGBOOMCOUNT);
	labelCount->setString(strBoomCount.getCString());

	_score += _enemyLayer->_smallVec.size()*SMALL_SCORE;
	_score += _enemyLayer->_midVec.size()*MID_SCORE;
	_score += _enemyLayer->_bigVec.size()*BIG_SCORE;
	_controlLayer->updateScore(_score);
	_enemyLayer->removeAllEnemy();
	if (_bigBoomCount == 0)
	{
		this->removeChildByTag(TAG_BIGBOOM);
		this->removeChildByTag(TAG_BIGBOOMCOUNT);
	}
}
Exemple #9
0
//ハイスコアラベルの表示
void GameScene::showHighScoreLabel()
{
    Size bgSize = m_background->getContentSize();
    
    //ハイスコア表示
    int highScore = UserDefault::getInstance()->getIntegerForKey(KEY_HIGHSCORE, 0);
    const char* highScoreStr = ccsf("%d", highScore);
    LabelBMFont* highScoreLabel = (LabelBMFont*)m_background->getChildByTag(kTagHighScoreLabel);
    if(!highScoreLabel)
    {
        //ハイスコア生成
        highScoreLabel = LabelBMFont::create(highScoreStr, FONT_WHITE);
        highScoreLabel->setPosition(ccp(bgSize.width * 0.78,bgSize.height * 0.87));
        m_background->addChild(highScoreLabel, kZOrderLabel, kTagHighScoreLabel);
    }
    else
    {
        highScoreLabel->setString(highScoreStr);
    }
    
}
Exemple #10
0
BallSprite* BallSprite::createWithNumber(kBallNumber number)
{
    BallSprite *ballSprite = new BallSprite();
    ballSprite->setNumber(number);
    if(ballSprite && ballSprite->initWithFile(PNG_BALL))
    {
        //ボールの数字をラベルとして付ける
        const char* numberString = CCString::createWithFormat("%d", number)->getCString();
        LabelBMFont* numberLabel = CCLabelBMFont::create(numberString, FONT_NUMBER);
        numberLabel->setPosition(Point(ballSprite->getContentSize().width / 2,ballSprite->getContentSize().height / 2));
        numberLabel->setScale(1.8);
        ballSprite->addChild(numberLabel, kZOrderNumber, kTagNumber);
        
        //ボールのメモリを自動消去
        ballSprite->autorelease();
        
        //作ったSpriteを返す
        return ballSprite;
    } else {
        CC_SAFE_DELETE(ballSprite);
        return nullptr;
    }
}
Exemple #11
0
void LeaderBoardAdvanceModeNode::addItemToSlide(const int& iStage, const char* sName, const char* sFacebookId, const int& iRank)
{
    Node* pNodeItem = Node::create();

    Sprite* pLoadAvatar = Sprite::create("Target-End-Game/border_avatar.png");
    pLoadAvatar->setPosition(Point(55.0f, 65.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(56.0f, 65.0f));
    pNodeItem->addChild(avatar);

    LabelTTF *pLabelName = LabelTTF::create(sName, "Arial", 20.0f);
    pLabelName->setColor(ccc3(0.0f, 0.0f, 0.0f));
    //pLabelName->setScale(0.80f);
    pLabelName->setAnchorPoint(Point(0.0f, 0.5f));
    pLabelName->setPosition(Point(26.0f, 17.0f));
    pNodeItem->addChild(pLabelName);

    char sStage[5];
    sprintf(sStage, "%d", iStage);
    LabelBMFont *pLabelNumberStage = LabelBMFont::create(sStage, "fonts/font-bechic.fnt");
    pLabelNumberStage->setAnchorPoint(Point(0.5f, 0.5f));
    pLabelNumberStage->setPosition(Point(130.0f, 85.0f));
    pLabelNumberStage->setScale(0.90);
    pNodeItem->addChild(pLabelNumberStage);

    LabelBMFont *pLabelStage = LabelBMFont::create("Stage", "fonts/font_small_alert.fnt");
    pLabelStage->setAnchorPoint(Point(0.5f, 0.5f));
    pLabelStage->setPosition(Point(130.0f, 50.0f));
    pLabelStage->setScale(0.8f);
    pNodeItem->addChild(pLabelStage);

    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 + (iRank-1)*160, -100.0f));
    m_pSlideShow->addChild(pNodeItem);
}
Exemple #12
0
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);
}
Exemple #13
0
//ラベル表示
void GameScene::showLabel()
{
    Size bgSize = m_background->getContentSize();
    
    //残数表示
    int tagsForLabel[] = {kTagRedLabel, kTagBlueLabel, kTagYellowLabel, kTagGreenLabel, kTagGrayLabel};
    const char* fontNames[] = {FONT_RED, FONT_BLUE, FONT_YELLOW, FONT_GREEN, FONT_GRAY};
    float heightRate[] = {0.61, 0.51, 0.41, 0.31, 0.21};
    
    //コマの種類のループ
    vector<kBlock>::iterator it = blockTypes.begin();
    while (it != blockTypes.end()) {
        //コマ残数表示
        long count = m_blockTags[*it].size();
        const char* countStr = ccsf("%02ld", count);
        
        LabelBMFont* label = (LabelBMFont*)m_background->getChildByTag(tagsForLabel[*it]);
        if (!label)
        {
            //コマ残数表示
            label = LabelBMFont::create(countStr, fontNames[*it]);
            label->setPosition(ccp(bgSize.width * 0.78, bgSize.height * heightRate[*it]));
            m_background->addChild(label, kZOrderLabel, tagsForLabel[*it]);
        }
        else
        {
            label->setString(countStr);
        }
        it++;
    }
    
    //スコア表示
    const char* scoreStr = ccsf("%d", m_score);
    LabelBMFont* scoreLabel = (LabelBMFont*)m_background->getChildByTag(kTagScoreLabel);
    if (!scoreLabel)
    {
        
        //スコア生成
        scoreLabel = LabelBMFont::create(scoreStr, FONT_WHITE);
        scoreLabel->setPosition(ccp(bgSize.width * 0.78, bgSize.height * 0.75));
        m_background->addChild(scoreLabel, kZOrderLabel, kTagScoreLabel);
    }
    else
    {
        scoreLabel->setString(scoreStr);
    }
    
}
Atlas6::Atlas6()
{
    auto s = Director::getInstance()->getWinSize();

    LabelBMFont* label = NULL;
    label = LabelBMFont::create("FaFeFiFoFu", "fonts/bitmapFontTest5.fnt");
    addChild(label);
    label->setPosition( Point(s.width/2, s.height/2+50) );
    label->setAnchorPoint( Point(0.5f, 0.5f) ) ;
    
    label = LabelBMFont::create("fafefifofu", "fonts/bitmapFontTest5.fnt");
    addChild(label);
    label->setPosition( Point(s.width/2, s.height/2) );
    label->setAnchorPoint( Point(0.5f, 0.5f) );

    label = LabelBMFont::create("aeiou", "fonts/bitmapFontTest5.fnt");
    addChild(label);
    label->setPosition( Point(s.width/2, s.height/2-50) );
    label->setAnchorPoint( Point(0.5f, 0.5f) ); 
}
Exemple #15
0
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;
}
//------------------------------------------------------------------
//
// AtlasBitmapColor
//
// Use any of these editors to generate BMFonts:
//     http://glyphdesigner.71squared.com/ (Commercial, Mac OS X)
//     http://www.n4te.com/hiero/hiero.jnlp (Free, Java)
//     http://slick.cokeandcode.com/demos/hiero.jnlp (Free, Java)
//     http://www.angelcode.com/products/bmfont/ (Free, Windows only)
//
//------------------------------------------------------------------
AtlasBitmapColor::AtlasBitmapColor()
{
    auto s = Director::getInstance()->getWinSize();
    
    LabelBMFont* label = NULL;
    label = LabelBMFont::create("Blue", "fonts/bitmapFontTest5.fnt");
    label->setColor( Color3B::BLUE );
    addChild(label);
    label->setPosition( Point(s.width/2, s.height/4) );
    label->setAnchorPoint( Point(0.5f, 0.5f) );

    label = LabelBMFont::create("Red", "fonts/bitmapFontTest5.fnt");
    addChild(label);
    label->setPosition( Point(s.width/2, 2*s.height/4) );
    label->setAnchorPoint( Point(0.5f, 0.5f) );
    label->setColor( Color3B::RED );

    label = LabelBMFont::create("G", "fonts/bitmapFontTest5.fnt");
    addChild(label);
    label->setPosition( Point(s.width/2, 3*s.height/4) );
    label->setAnchorPoint( Point(0.5f, 0.5f) );
    label->setColor( Color3B::GREEN );
    label->setString("Green");
}
Exemple #17
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 #18
0
bool LeaderBoardtNode::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("HIGH SCORE", "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);
    m_pSlideShow->addChild(m_pButtonManagerNode);

    m_pScrollManager = new ScrollManager();
    m_iLeaderBoardCount = 0;

    for(int iIndex=0; iIndex<6; iIndex++)
    {
        m_arrIndex[iIndex] = -1;
    }

#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()->getLeaderBoardLevel(m_sChapterId ,m_iLevel, 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()->getLeaderBoardLevel(m_sChapterId ,m_iLevel, m_iConnectServer);
    */

    return true;
}
Exemple #19
0
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);
					}
				}
			}
		}
	}
}
Exemple #20
0
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;
}
Exemple #21
0
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;
}
Exemple #22
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;
}
Exemple #23
0
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;
}