void CocosGUIExamplesPageScene::onEnter()
{
    CCScene::onEnter();
    
    m_pUILayer = UILayer::create();
    m_pUILayer->scheduleUpdate();
    addChild(m_pUILayer);
    
    PageInit();
    
    CCSize winSize = CCDirector::sharedDirector()->getWinSize();
    
    UILabel* label = UILabel::create();
    label->setText("Move by horizontal direction");
    label->setFontName("Marker Felt");
    label->setFontSize(32);
    label->setAnchorPoint(ccp(0.5f, -1));
    label->setPosition(ccp(winSize.width / 2.0f, winSize.height / 2.0f + label->getContentSize().height * 1.5));
    m_pUILayer->addWidget(label);
    
    // left button
    UIButton* left_button = UIButton::create();
    left_button->setTouchEnable(true);
    left_button->loadTextures("cocosgui/UITest/b1.png", "cocosgui/UITest/b2.png", "");
    float left_button_width = left_button->getContentSize().width;
    left_button->setPosition(ccp(left_button_width - left_button_width / 2, m_pUILayer->getContentSize().height / 2));
    left_button->addReleaseEvent(this, coco_releaseselector(CocosGUIExamplesPageScene::toCocosGUIExamplesMapScene));
    m_pUILayer->addWidget(left_button);
}
Esempio n. 2
0
void LayerGameChan_KetQua::displayResuilt(string resuilt){
	vector<string> arrResuilt = splitString(resuilt,';');

	CCLog("winner user: %s", arrResuilt[2].c_str());
	CCLog("den lang user: %s", arrResuilt[3].c_str());
	CCLog("win cuoc sac: %s", arrResuilt[4].c_str());
	CCLog("den lang cuoc sac: %s", arrResuilt[5].c_str());
	CCLog("Tong diem: %s", arrResuilt[6].c_str());
	CCLog("danh sach tinh tien: %s", arrResuilt[7].c_str());
	if (arrResuilt.size() >= 9)
	{
		CCLog("Cac cuoc thieu: %s", arrResuilt[8].c_str());
	}
	if (arrResuilt.size() >= 10)
	{
		CCLog("Cac cuoc co ga: %s", arrResuilt[9].c_str());
	}
	

	if(atoi(arrResuilt[6].c_str()) == 0){
		UILabel *ttt = UILabel::create();
		ttt->setText("Hòa cả làng");
		ttt->setFontSize(20);
		ttt->setColor(ccRED);
		img->addChild(ttt);
		return;
	}

	string str = "";

	//Xác định người thắng
	if (strcmp(arrResuilt[2].c_str(), "") != 0)
	{
		str += getNamePlayer(arrResuilt[2]) + " xướng: " + getCuoc(arrResuilt[4], true) + "\n";
		if (arrResuilt.size() >= 10 && arrResuilt[9] != "")
		{
			str += "Cước có gà: "+getCuoc(arrResuilt[9], false) + "\n";
		}
	}

	//Xác định người thua
	if (strcmp(arrResuilt[3].c_str(), "") != 0){
		str += getNamePlayer(arrResuilt[3]) + " Đền làng: " + getCuoc(arrResuilt[5], true) + (getCuoc(arrResuilt[8], true) == "" ? "" : "\n");
		if (strcmp(arrResuilt[8].c_str(), "") != 0)
		{
			str += "Xướng thiếu " + getCuoc(arrResuilt[8], true) + "\n";
		}
	}
	
	str += "Tổng điểm: "+arrResuilt[6];

	//Tính tiền
	string strScore = "";
	if (strcmp(arrResuilt[7].c_str(), "") != 0)
	{
		vector<string> arrTinhtien = splitString(arrResuilt[7],'/');
		for (int i = 0; i < arrTinhtien.size(); i++)
		{
			vector<string> info = splitString(arrTinhtien[i],':');
			strScore += getNamePlayer(info[0]) + ": " + info[2] + "\n";
		}
	}

	UILabel *content1 = UILabel::create();
	content1->setText(str.c_str());
	content1->setFontSize(17);
	content1->setColor(ccRED);
	content1->setAnchorPoint(ccp(0.5, 0));
	content1->setPosition(ccp(0, 5));
	img->addChild(content1);

	UILabel *content = UILabel::create();
	content->setText(strScore.c_str());
	content->setFontSize(17);
	content->setColor(ccRED);
	content->setAnchorPoint(ccp(0.5, 1));
	img->addChild(content);

}