void updateScroll(){
		bool vBar = _scrollBar && _scrollBar->isVisible(),
			vNode = _scrollNode && _scrollNode->isVisible();
		if(!vBar || !vNode){
			return;
		}
		bool vert = getDirection() == kCCScrollViewDirectionVertical;
		CCPoint p, cp = getContentOffset();
		CCSize vs = getViewSize(),
			cs = getContentSize();
		float rate = 1 - (vert? fabsf(cp.y) / (cs.height - vs.height) : fabsf(cp.x) / (cs.width - vs.width));
		if(vBar){
			CCSize ss = _scrollBar->getPreferredSize();
			p = _scrollBar->getPosition();
			if(vert){	p.y = cs.height - (cs.height - ss.height) * rate - ss.height - _scrollTrackDelta;
			}else{		p.x = cs.width - (cs.width - ss.width) * rate - ss.width - _scrollTrackDelta;
			}
			_scrollBar->setPosition(p);
		}
		if(vNode){
			p = _scrollNode->getPosition();
			if(vert){	p.y = cp.y + vs.height * rate;
			}else{		p.x = cp.x + vs.width * rate;
			}
			_scrollNode->setPosition(p);
		}
		if(_scrollTrack){
			p = _scrollTrack->getPosition();
			if(vert){	p.y = fabsf(cp.y);
			}else{		p.x = fabsf(cp.x);
			}
			_scrollTrack->setPosition(p);
		}
//CCLog("LuaTableView.updateScroll ss=%d,%d vh=%d cy=%d ch=%d y=%d", (int)ss.width, (int)ss.height, (int)vs.height, (int)p.y, (int)cs.height, (int)_scrollBar->getPositionY());
	}
Beispiel #2
0
bool VVAlertViewForLogin::initWithTitle(const char* aTitle, const char* aMessage, VVAlertViewDelegate* aDelegate, const char* aCancelBtnTitle, const char* aOtherBtnTitle,
                                        const char* aPlaceHolderUser, const char* aPlaceHolderPassword, VVTextFieldDelegate* aTextDelegate)
{
    if( !VVAlertView::initWithTitle(aTitle, aMessage, aDelegate, aCancelBtnTitle,aOtherBtnTitle,centerPadding) )
        return false;

    float txtBoxPaddingLeft = 10;
    float txtBoxPaddingTop = 5;
    CCScale9Sprite *txtbg = CCScale9Sprite::scale9SpriteWithFile(paramUser.fieldBG_name.c_str(), paramUser.field9patch_rect);
    if( txtbg )
    {
        txtbg->setContentSize(CCSizeMake(paramUser.fieldSize.width+txtBoxPaddingLeft*2, paramUser.fieldSize.height+txtBoxPaddingTop*2));
        txtbg->setAnchorPoint(ccp(0.5,0));
        txtbg->setPosition(ccp(0, centerOfMargin+paramUser.fieldSize.height*4/5-txtBoxPaddingTop));
        addChild(txtbg);
    }

    txtbg = NULL;
    txtbg = CCScale9Sprite::scale9SpriteWithFile(paramPassword.fieldBG_name.c_str(), paramPassword.field9patch_rect);
    if( txtbg )
    {
        txtbg->setContentSize(CCSizeMake(paramUser.fieldSize.width+txtBoxPaddingLeft*2, paramUser.fieldSize.height+txtBoxPaddingTop*2));
        txtbg->setAnchorPoint(ccp(0.5,0));
        txtbg->setPosition(ccp(0, centerOfMargin-paramPassword.fieldSize.height*4/5-txtBoxPaddingTop));
        addChild(txtbg);
    }


    txtUser = new VVTextField();
    txtUser->initWithPlaceHolder(aPlaceHolderUser, fontName.c_str(), paramUser.textFieldFontSize, paramUser.maxFieldLength, paramUser.fieldSize);
    txtUser->setPosition(ccp(-paramUser.fieldSize.width/2, centerOfMargin+paramUser.fieldSize.height*4/5));
    txtUser->setDelegate(aTextDelegate);
    txtUser->setTag(VVAlertViewForLoginTypeUser);
    txtUser->setIsAcceptingOnlyASCII(true);

    addChild(txtUser);
    txtUser->release();


    txtPassword = new VVTextField();
    txtPassword->initWithPlaceHolder(aPlaceHolderPassword, fontName.c_str(), paramPassword.textFieldFontSize, paramPassword.maxFieldLength, paramPassword.fieldSize);
    txtPassword->setPosition(ccp(-paramPassword.fieldSize.width/2, centerOfMargin-paramPassword.fieldSize.height*4/5));
    txtPassword->setDelegate(aTextDelegate);
    txtPassword->setTag(VVAlertViewForLoginTypePassword);
    txtPassword->setIsPasswordText(true);
    txtPassword->setIsAcceptingOnlyASCII(true);

    addChild(txtPassword);
    txtPassword->release();


    return true;
}
bool MoreDiamondDialog::init()
{
    if ( !CCLayerColor::initWithColor(DIM_COLOR) )
    {
        return false;
    }

	CCPoint pask = ccp(400, 1280 - 1000);
	
	CCScale9Sprite* dialog = CCScale9Sprite::create("dialog.png");
	dialog->setPosition(ccp(400, 1280-750));
	dialog->setContentSize(CCSizeMake(768, 640));
	this->addChild(dialog);

	CCScale9Sprite* dialogTop = CCScale9Sprite::create("dialog.png");
	dialogTop->setPosition(ccp(400, 1280-481));
	dialogTop->setContentSize(CCSizeMake(768, 100));
	this->addChild(dialogTop);

	MY_ADD_LABELTTF(labelTitle, "Thêm kim cương", CONF_STR(FONT_NORMAL), 48, ccBLACK, ccp(400, 1280 - 484));

	MY_ADD_MENU_ITEM_LABEL(itlbRate, CCString::createWithFormat("+ %d: Rate 5 sao", CONF_INT(DIAMOND_FOR_RATE))->getCString(), 
		CONF_STR(FONT_NORMAL), 48, ccBLACK, MoreDiamondDialog::rateCallback, ANCHOR_LEFT, ccp(188, 1280-628));
	MY_ADD_MENU_ITEM_LABEL(itlbInvite, CCString::createWithFormat("+ %d: Mời 1 bạn", CONF_INT(DIAMOND_FOR_INVITE))->getCString(),
		CONF_STR(FONT_NORMAL), 48, ccBLACK, MoreDiamondDialog::inviteCallback, ANCHOR_LEFT, ccp(188, 1280-738));
	MY_ADD_MENU_ITEM_LABEL(itlbShare, CCString::createWithFormat("+ %d: Chia sẻ", CONF_INT(DIAMOND_FOR_SHARE))->getCString(), 
		CONF_STR(FONT_NORMAL), 48, ccBLACK, MoreDiamondDialog::shareCallback, ANCHOR_LEFT, ccp(188, 1280-848));

	m_itlbRate = itlbRate;
	m_itlbInvite = itlbInvite;
	m_itlbShare = itlbShare;

	MY_ADD_SPRITE(sprRate, "rateIcon.png", ccp(108, 1280-628));
	MY_ADD_SPRITE(sprInvite, "inviteIcon.png", ccp(108, 1280-738));
	MY_ADD_SPRITE(sprShare, "shareIcon.png", ccp(108, 1280-848));

	//check
	if (DataManager::sharedDataManager()->GetIsRatedApp() == true)
	{
		m_itlbRate->setEnabled(false);
		m_itlbRate->setOpacity(100);
	}


	MY_ADD_MENU_ITEM(itExit, "exit_button.png", "exit_button_press.png", "exit_button_press.png", MoreDiamondDialog::exitCallback, pask);

	this->setKeypadEnabled(true);
    return true;
}
Beispiel #4
0
bool ToTextLayer::DerSelMenu(Script* ts){
	do{
		CC_BREAK_IF(!ts);
		//CCDictionary* attrs = ts->attributes;
		CCArray* scrs = ts->scriptnodes;
		int n = ts->m_snum;
		int maxleng = 0;	/* <最大字长 */

		CCArray* tm = CCArray::createWithCapacity(n);
		for(int i=0;i<n;i++){
			Script* tmp = (Script*) scrs->objectAtIndex(i);		//set more here if you want more.

			float sf = 1;
			CCSprite* spriteNormal; 
			CCSprite* spriteSelected;
			CCSprite* spriteDisabled;

			spriteNormal = CCSprite::create("Images/menuitemsprite2.png", CCRectMake(0,23*2/sf,70/sf,23/sf));
			spriteSelected = CCSprite::create("Images/menuitemsprite2.png", CCRectMake(0,23*1/sf,70/sf,23/sf));
			spriteDisabled = CCSprite::create("Images/menuitemsprite2.png", CCRectMake(0,23*0,70/sf,23/sf));

			SpriteTextMenuItem* item2 = new SpriteTextMenuItem();
			item2->autorelease();
			item2->initWithNormalSprite(spriteNormal, spriteSelected, spriteDisabled,this, menu_selector(ToTextLayer::menucallback) );
			item2->settext(tmp->getstring("content"), FNT_CHN, 24);
			item2->setSData(tmp->getint("jump"));
			item2->setTag(100+i);

			maxleng = max(maxleng, strlen(tmp->getstring("content")));

			tm->insertObject(item2,i);
		}
		sel_menu = MouseMenu::createWithArray(tm);	

		sel_menu->setTouchEnabled(false);
		sel_menu->alignItemsVertically();
		sel_menu->setTag(MENUTAG);
		sel_menu->setPosition(ccp(s.width/2, s.height/2));
		sel_menu->f_setaligntype(1);
		addChild(sel_menu);

		float t_width,t_height;

		t_width = maxleng * 30;
		t_height = n * 30;

		CCScale9Sprite* nback = CCScale9Sprite::create("Images/popup_back.png"); 
		nback->setContentSize(CCSize(t_width+ 23,t_height+ 22));
		nback->setAnchorPoint(ccp(0.5,0.5));
		nback->setPosition(s.width/2, s.height/2 - t_height/2 +30 );
		nback->setOpacity(200);
		nback->setTag(MENUTAG+1);
		addChild(nback,-1);

		e_layerstate = 1;

		return true;
	}while(0);
	return false;
}
Beispiel #5
0
LFToast::LFToast(string msg,float during)
{
	CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
	CCScale9Sprite* base = CCScale9Sprite::create("toast.png");
	CCLabelTTF* lable = CCLabelTTF::create(
		msg.c_str(),
		fontStr_kaiti,
		30,
		CCSize(base->getContentSize().width - 10,0), 
		kCCTextAlignmentLeft);
	lable->setAnchorPoint(ccp(0,0.5f));
	addChild(base);
	base->setContentSize(CCSizeMake(base->getContentSize().width,lable->getContentSize().height + 20));
	base->setOpacity(0);
	base->addChild(lable);
	lable->setPosition(ccp(10,base->getContentSize().height/2));
	base->setPosition(ccp(visibleSize.width/2,base->getContentSize().height + 20));
	base->runAction(CCSequence::create(
		CCFadeTo::create(0.2f,255),
		CCDelayTime::create(during),
		CCFadeTo::create(0.1f,0),
		CCCallFuncN::create(this,SEL_CallFuncN(&LFToast::removeToast)),
		NULL
		));
}
Beispiel #6
0
void PopupLayer::onEnter(){
	CCLayer::onEnter();

	CCSize winSize = CCDirector::sharedDirector()->getWinSize();
	CCPoint pCenter = ccp(winSize.width / 2, winSize.height / 2);

	CCSize contentSize;
	if (getContentSize().equals(CCSizeZero)) {
		getSpriteBackGround()->setPosition(ccp(winSize.width / 2, winSize.height / 2));
		this->addChild(getSpriteBackGround(), 0, 0);
		contentSize = getSpriteBackGround()->getTexture()->getContentSize();
	} else {
		CCScale9Sprite *background = getSprite9BackGround();
		background->setContentSize(getContentSize());
		background->setPosition(ccp(winSize.width / 2, winSize.height / 2));
		this->addChild(background, 0, 0);
		contentSize = getContentSize();
	}

	this->addChild(getMenuButton());
	float btnWidth = contentSize.width / (getMenuButton()->getChildrenCount() + 1);

	CCArray* array = getMenuButton()->getChildren();
	CCObject* pObj = NULL;
	int i = 0;
	CCARRAY_FOREACH(array, pObj){
		CCNode* node = dynamic_cast<CCNode*>(pObj);
		node->setPosition(ccp( winSize.width / 2 - contentSize.width / 2 + btnWidth * (i + 1), winSize.height / 2 - contentSize.height / 3));
		i++;
	}
void SoloGameScene::initQuestionItems()
{
	int boxW = 774;

	CCScale9Sprite* quesContent = CCScale9Sprite::create("dialog.png");
	quesContent->setPosition(ccp(400, 1280-588));
	quesContent->setContentSize(CCSizeMake(boxW, 412));
	this->addChild(quesContent);

	CCScale9Sprite* quesNumber = CCScale9Sprite::create("dialog.png");
	quesNumber->setPosition(ccp(400, 1280-345));
	quesNumber->setContentSize(CCSizeMake(390, 128));
	this->addChild(quesNumber);

	
	MY_ADD_LABELTTF( _lbNumber, "", CONF_STR(FONT_NORMAL), 64, ccBLACK, ccp(400, 1280-340));
	m_lbNumber = _lbNumber;

	m_lbQuestion = CCLabelTTF::create("", 
		CONF_STR(FONT_NORMAL), 
		48, 
		CCSizeMake(9.0f * boxW / 10.0f, 0), 
		kCCTextAlignmentCenter, 
		kCCVerticalTextAlignmentCenter);
	m_lbQuestion->setFontFillColor(ccBLACK);
	m_lbQuestion->setColor(ccBLACK);
	m_lbQuestion->setPosition(ccp(400, 1280-600));
	this->addChild(m_lbQuestion);

	for (int i = 0; i < 4; ++i)
	{
		m_itAnswers[i] = CCMenuItemImage::create("answer.png", "answer_down.png", "answer_disable.png", this, menu_selector(SoloGameScene::answerCallback));
		m_itAnswers[i]->setPosition(ccp(400, 1280-843 - i*94));
		m_itAnswers[i]->setTag(i);
		m_menu->addChild(m_itAnswers[i]);
	}

	for (int i = 0; i < 4; ++i)
	{
		m_lbAnswers[i] = CCLabelTTF::create("", CONF_STR(FONT_NORMAL), 48);
		m_lbAnswers[i]->setFontFillColor(ccBLACK);
		m_lbAnswers[i]->setColor(ccBLACK);
		m_lbAnswers[i]->setAnchorPoint(ANCHOR_LEFT);
		m_lbAnswers[i]->setPosition(ccp(140, 1280-840 - i*94));
		this->addChild(m_lbAnswers[i]);
	}
}
Beispiel #8
0
CCScale9Sprite* TFBaseLayer::createTile(const char* spriteFrameName, CCSize size, CCPoint position)
{
    CCScale9Sprite* tile = CCScale9Sprite::createWithSpriteFrameName(spriteFrameName);
    tile->setPreferredSize(size);
    tile->setAnchorPoint(ccp(0.5f, 0.5f));
    tile->setPosition(position);
    
    return tile;
}
Beispiel #9
0
LayerChanToast::LayerChanToast(string message){
	vector<string> lstRegex;
	for( int i = 1; i <= 16; i++ ){
		lstRegex.push_back( CCString::createWithFormat("(%d)", i)->getCString() );
	}

	this->setAnchorPoint(ccp(0, 0));
	// text
	cocos2d::ui::RichText* label = cocos2d::ui::RichText::create();
	label->setAnchorPoint(ccp(0, 0));
	label->setPosition(ccp(0, HEIGHT_DESIGN / 3.5));

	vector<string> lstContents = mUtils::splitStringByListRegex(message, lstRegex);
	int wLabel = 0, hLabel = 0;
	for( int i = 0; i < lstContents.size(); i++ ){
		bool check = false;
		int j = 0;
		for( j = 0; j < lstRegex.size(); j++ )
			if( lstRegex.at(j) == lstContents.at(i) ){
				check = true;
				break;
			}
			if( check ){
				CCArmature *armature = CCArmature::create(CCString::createWithFormat("onion%d", 1)->getCString());
				armature->getAnimation()->playByIndex(j);
				cocos2d::ui::RichElementCustomNode* recustom = cocos2d::ui::RichElementCustomNode::create(1, ccWHITE, 255, armature);
				label->pushBackElement(recustom);
				wLabel += 50;
				hLabel = 55;
			}else{
				CCLabelTTF *l = CCLabelTTF::create(lstContents.at(i).c_str(), "Arial", 16);
				l->setColor(ccc3(204, 16, 85));
				cocos2d::ui::RichElementText* re1 = cocos2d::ui::RichElementText::create(1, ccWHITE, 255, lstContents.at(i).c_str(), "Arial", 16);
				label->pushBackElement(re1);
				wLabel += l->getContentSize().width;
				hLabel = hLabel > 50 ? 55 : l->getContentSize().height;
			}
	}
	this->addChild(label, 1, 0);

	CCSize sizeDesign = CCSize(169, 30);
	CCSpriteBatchNode *batchNode = CCSpriteBatchNode::create("chats/framechat_a.png");
	CCScale9Sprite *blocks = CCScale9Sprite::create();
	blocks ->updateWithBatchNode(batchNode , CCRect(0, 0, sizeDesign.width, sizeDesign.height), false, CCRect(10, 10, sizeDesign.width - 20, sizeDesign.height - 20));

	CCSize size = CCSizeMake(wLabel + 10, hLabel + 5);
	blocks ->setContentSize(size);
	blocks->setAnchorPoint(ccp(0.5, 0.5));
	blocks->setPosition(ccp(label->getPositionX() + wLabel / 2, label->getPositionY() + hLabel / 2));

	blocks->setColor(ccc3(84, 81, 69));
	blocks->setOpacity(200);
	this->setPosition(ccp((WIDTH_DESIGN - size.width) / 2, 100));
	// add
	this->addChild(blocks);
}
	void resetScroll(){
		if(!_scrollBar){ return;}
		CCSize vs = getViewSize(), cs = getContentSize();
		bool vert = getDirection() == kCCScrollViewDirectionVertical;
		bool v = vert? vs.height < cs.height : vs.width < cs.height;
		_scrollBar->setVisible(v);
		CCPoint p = ccp(0, 0), ap = vert? ccp(1,0) : CCPointZero;
		if(v){
			CCSize s = _scrollBar->getPreferredSize(),
				st = _scrollTrack? _scrollTrack->getPreferredSize() : CCSizeZero;
			if(vert){
				p.x = vs.width + _scrollOffset - (st.width > 0? (st.width - s.width) / 2 : 0);
				_scrollTrackDelta = st.height > 0? (st.height - s.height) / 2 : 0;
				s.height = vs.height / cs.height * vs.height - _scrollTrackDelta * 2;
			}else{
				p.y = vs.height + _scrollOffset - (st.height > 0? (st.height - s.height) / 2 : 0);
				_scrollTrackDelta = st.width > 0? (st.width - s.width) / 2 : 0;
				s.width = vs.width / cs.width * vs.width - _scrollTrackDelta * 2;
			}
			_scrollBar->setAnchorPoint(ap);
			_scrollBar->setPreferredSize(s);
			_scrollBar->setPosition(p);
//CCLog("LuaTableView vScroll.size=%d,%d vh=%d ch=%d", (int)s.width, (int)s.height, (int)vs.height, (int)cs.height);
		}
		if(_scrollTrack){
			_scrollTrack->setVisible(v);
			if(v){
				CCSize s = _scrollTrack->getPreferredSize();
				if(vert){
					p.x = vs.width + _scrollOffset;
					s.height = vs.height;
				}else{
					p.y = vs.height + _scrollOffset;
					s.width = vs.width;
				}
				_scrollTrack->setAnchorPoint(ap);
				_scrollTrack->setPreferredSize(s);
				_scrollTrack->setPosition(p);
			}
		}
//CCLog("LuaTableView reload vscr=%x visible=%d", _scroller, _scrollBar->isVisible());
		updateScroll();
	}
void AchievementNotification::showImmediately(Achievement a)
{
	mShowing = true;
	CCTexture2D* tex = CCTextureCache::sharedTextureCache()->textureForKey(fileName.c_str());
	if (tex == NULL)
	{
		tex = CCTextureCache::sharedTextureCache()->addImage(fileName.c_str());
	}
	CCSize winSize = CCDirector::sharedDirector()->getWinSize();


	CCScale9Sprite* pBoard = CCScale9Sprite::create(CCRectMake(tex->getContentSize().width/2, 0, 2, tex->getContentSize().height), fileName.c_str());
	addChild(pBoard,0,Tag_Board);
	pBoard->setPosition(ccp(winSize.width/2,winSize.height + pBoard->getContentSize().height) );

	CCSprite* pJinBei = CCSprite::create(ResManager::getManager()->getFilePath(g_public+"CJ_icon_jiangbei.png").c_str());
	pBoard->addChild(pJinBei, 1);
	pJinBei->setPosition(ccp(pJinBei->getContentSize().width, pBoard->getContentSize().height/2));

	CCLabelTTF* pName = CCLabelTTF::create(a.name.c_str(), fontStr_KlavikaBold, 40);
	pName->setColor(fontColor_Acheivement_TTF);
	CCSprite* pIcon = CCSprite::create(ResManager::getManager()->getFilePath(g_public+"CJ_icon_wancheng.png").c_str());
	int x = pName->getContentSize().width + pIcon->getContentSize().width - 420;
	if (x > 0)
	{
		pBoard->setContentSize(ccp(pBoard->getContentSize().width+x, pBoard->getContentSize().height));
	}
	pBoard->addChild(pName);

	int xoffset = 10;

	pName->setPosition(ccp(pBoard->getContentSize().width/2 + pIcon->getContentSize().width/2 + xoffset, pBoard->getContentSize().height/2));

	pBoard->addChild(pIcon);
	pIcon->setPosition(ccp(pName->getPositionX() - pName->getContentSize().width/2 - pIcon->getContentSize().width/2 - xoffset, pName->getPositionY()));

	Achievement* achievementCopy = new Achievement(a);
//	*achievementCopy = a;
	temp_Must_Delete.insert(temp_Must_Delete.end(),achievementCopy);

	pBoard->runAction(CCSequence::create(
		CCMoveTo::create(0.5f,ccp(pBoard->getPositionX(),winSize.height-pBoard->getContentSize().height/2)),
		CCDelayTime::create(0.1f),
		CCCallFuncND::create(this,SEL_CallFuncND(&AchievementNotification::boardShowing),achievementCopy),
		CCDelayTime::create(1.3f),
		CCMoveTo::create(0.2f,ccp(pBoard->getPositionX(),winSize.height+pBoard->getContentSize().height)),
		CCFadeTo::create(0.1f,0),
		CCCallFuncN::create(this,SEL_CallFuncN(&AchievementNotification::boardShowEnd)),NULL));

	createPar(ccp(winSize.width/2,winSize.height),parFileName.c_str(),pBoard->getContentSize().width * 1.2f,pBoard->getContentSize().height);

	Music::sharedMusicPlayer()->playEffectSound("achievement.wav");

	CCLog("AchievementNotification::showImmediately name = %s" ,a.name.c_str());
}
bool CCControlPotentiometerTest::init()
{
    if (CCControlScene::init())
    {
        CCSize screenSize = CCDirector::sharedDirector()->getWinSize();
        
        CCNode *layer = CCNode::create();
        layer->setPosition(ccp (screenSize.width / 2, screenSize.height / 2));
        this->addChild(layer, 1);
        
        double layer_width = 0;
        
        // Add the black background for the text
        CCScale9Sprite *background  = CCScale9Sprite::create("extensions/buttonBackground.png");
        background->setContentSize(CCSizeMake(80, 50));
        background->setPosition(ccp(layer_width + background->getContentSize().width / 2.0f, 0));
        layer->addChild(background);
        
        layer_width += background->getContentSize().width;
        
        this->setDisplayValueLabel(CCLabelTTF::create("", "HelveticaNeue-Bold", 30));

        m_pDisplayValueLabel->setPosition(background->getPosition());
        layer->addChild(m_pDisplayValueLabel);
		
        // Add the slider
        CCControlPotentiometer *potentiometer = CCControlPotentiometer::create("extensions/potentiometerTrack.png"
                                                                                ,"extensions/potentiometerProgress.png"
                                                                                ,"extensions/potentiometerButton.png");
        potentiometer->setPosition(ccp (layer_width + 10 + potentiometer->getContentSize().width / 2, 0));

        // When the value of the slider will change, the given selector will be call
        potentiometer->addTargetWithActionForControlEvents(this, cccontrol_selector(CCControlPotentiometerTest::valueChanged), CCControlEventValueChanged);
        
		layer->addChild(potentiometer);
        
        layer_width += potentiometer->getContentSize().width;
        
        // Set the layer size
        layer->setContentSize(CCSizeMake(layer_width, 0));
        layer->setAnchorPoint(ccp (0.5f, 0.5f));
        
        // Update the value label
        this->valueChanged(potentiometer, CCControlEventValueChanged);
        return true;
	}
	return false;
}
Beispiel #13
0
bool CCControlScene::init()
{
    if (CCLayer::init())
    {    
        // Get the sceensize
        CCSize screensize = CCDirector::sharedDirector()->getWinSize();

        CCMenuItemFont* pBackItem = CCMenuItemFont::create("Back", this,
            menu_selector(CCControlScene::toExtensionsMainLayer));
        pBackItem->setPosition(ccp(screensize.width - 50, 25));
        CCMenu* pBackMenu = CCMenu::create(pBackItem, NULL);
        pBackMenu->setPosition( CCPointZero );
        addChild(pBackMenu, 10);

        // Add the generated background
        CCSprite *background = CCSprite::create("extensions/background.png");
        background->setPosition(ccp(screensize.width / 2, screensize.height / 2));
        addChild(background);
        
        // Add the ribbon
        CCScale9Sprite *ribbon = CCScale9Sprite::create("extensions/ribbon.png", CCRectMake(1, 1, 48, 55));
        ribbon->setContentSize(CCSizeMake(screensize.width, 57));
        ribbon->setPosition(ccp(screensize.width / 2.0f, screensize.height - ribbon->getContentSize().height / 2.0f));
        addChild(ribbon);
        
        // Add the title
        setSceneTitleLabel(CCLabelTTF::create("Title", "Arial", 12));
        m_pSceneTitleLabel->setPosition(ccp (screensize.width / 2, screensize.height - m_pSceneTitleLabel->getContentSize().height / 2 - 5));
        addChild(m_pSceneTitleLabel, 1);
        
        // Add the menu
        CCMenuItemImage *item1 = CCMenuItemImage::create("Images/b1.png", "Images/b2.png", this, menu_selector(CCControlScene::previousCallback));
        CCMenuItemImage *item2 = CCMenuItemImage::create("Images/r1.png", "Images/r2.png", this, menu_selector(CCControlScene::restartCallback));
        CCMenuItemImage *item3 = CCMenuItemImage::create("Images/f1.png", "Images/f2.png", this, menu_selector(CCControlScene::nextCallback));
        
        CCMenu *menu = CCMenu::create(item1, item3, item2, NULL);
        menu->setPosition(CCPointZero);
        item1->setPosition(ccp(screensize.width / 2 - 100, 37));
        item2->setPosition(ccp(screensize.width / 2, 35));
        item3->setPosition(ccp(screensize.width / 2 + 100, 37));
        
        addChild(menu ,1);

        return true;
    }
    return false;
}
bool CCControlButtonTest_HelloVariableSize::init()
{
    if (CCControlScene::init())
    {
        CCSize screenSize = CCDirector::sharedDirector()->getWinSize();
        
        // Defines an array of title to create buttons dynamically
        CCArray *stringArray = CCArray::create(
            ccs("Hello"),
            ccs("Variable"),
            ccs("Size"),
            ccs("!"),
            NULL);
        
        CCNode *layer = CCNode::create();
        addChild(layer, 1);
        
        double total_width = 0, height = 0;
        
        // For each title in the array
        CCObject* pObj = NULL;
        CCARRAY_FOREACH(stringArray, pObj)
        {
            CCString* title = (CCString*)pObj;
            // Creates a button with this string as title
            CCControlButton *button = standardButtonWithTitle(title->getCString());
            button->setPosition(ccp (total_width + button->getContentSize().width / 2, button->getContentSize().height / 2));
            layer->addChild(button);
            
            // Compute the size of the layer
            height = button->getContentSize().height;
            total_width += button->getContentSize().width;
        }

        layer->setAnchorPoint(ccp (0.5, 0.5));
        layer->setContentSize(CCSizeMake(total_width, height));
        layer->setPosition(ccp(screenSize.width / 2.0f, screenSize.height / 2.0f));
        
        // Add the black background
        CCScale9Sprite *background = CCScale9Sprite::create("extensions/buttonBackground.png");
        background->setContentSize(CCSizeMake(total_width + 14, height + 14));
        background->setPosition(ccp(screenSize.width / 2.0f, screenSize.height / 2.0f));
        addChild(background);
        return true;
    }
Beispiel #15
0
bool CCControlScene::init()
{
    if (CCLayer::init())
    {    
        CCMenuItemFont* pBackItem = CCMenuItemFont::create("Back", this,
            menu_selector(CCControlScene::toExtensionsMainLayer));
        pBackItem->setPosition(ccp(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25));
        CCMenu* pBackMenu = CCMenu::create(pBackItem, NULL);
        pBackMenu->setPosition( CCPointZero );
        addChild(pBackMenu, 10);

        // Add the generated background
        CCSprite *background = CCSprite::create("extensions/background.png");
        background->setPosition(VisibleRect::center());
        addChild(background);
        
        // Add the ribbon
        CCScale9Sprite *ribbon = CCScale9Sprite::create("extensions/ribbon.png", CCRectMake(1, 1, 48, 55));
        ribbon->setContentSize(CCSizeMake(VisibleRect::getVisibleRect().size.width, 57));
        ribbon->setPosition(ccp(VisibleRect::center().x, VisibleRect::top().y - ribbon->getContentSize().height / 2.0f));
        addChild(ribbon);
        
        // Add the title
        setSceneTitleLabel(CCLabelTTF::create("Title", "Arial", 12));
        m_pSceneTitleLabel->setPosition(ccp (VisibleRect::center().x, VisibleRect::top().y - m_pSceneTitleLabel->getContentSize().height / 2 - 5));
        addChild(m_pSceneTitleLabel, 1);
        
        // Add the menu
        CCMenuItemImage *item1 = CCMenuItemImage::create("Images/b1.png", "Images/b2.png", this, menu_selector(CCControlScene::previousCallback));
        CCMenuItemImage *item2 = CCMenuItemImage::create("Images/r1.png", "Images/r2.png", this, menu_selector(CCControlScene::restartCallback));
        CCMenuItemImage *item3 = CCMenuItemImage::create("Images/f1.png", "Images/f2.png", this, menu_selector(CCControlScene::nextCallback));
        
        CCMenu *menu = CCMenu::create(item1, item3, item2, NULL);
        menu->setPosition(CCPointZero);
        item1->setPosition(ccp(VisibleRect::center().x - item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
        item2->setPosition(ccp(VisibleRect::center().x, VisibleRect::bottom().y+item2->getContentSize().height/2));
        item3->setPosition(ccp(VisibleRect::center().x + item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
        
        addChild(menu ,1);

        return true;
    }
    return false;
}
Beispiel #16
0
void ModelDialog::onEnter(){
    CCLayer::onEnter();
    
    CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
    CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();
    
    CCSize contentSize;
    if (getContentSize().equals(CCSizeZero)) {
        getSpriteBackGround()->setPosition(ccp(origin.x + visibleSize.width / 2 , origin.y + visibleSize.height / 2));
        this->addChild(getSpriteBackGround(), 0, 0);
        contentSize = getSpriteBackGround()->getTexture()->getContentSize();
    } else {
        contentSize = getContentSize();
        CCScale9Sprite *background = getSprite9BackGround();
        background->setContentSize(getContentSize());
        background->setPosition(ccp(contentSize.width / 2, contentSize.height / 2));
        this->addChild(background, 0, 0);
        
    }
    
    CCMenu* menu = CCMenu::createWithArray(mButtonArray);
    menu->setPosition(ccp(0,0));
    addChild(menu);
    
    if (getLabelTitle()){
        CCSize titleSize = getLabelTitle()->getContentSize();
        getLabelTitle()->setPosition(ccp(contentSize.width/2, contentSize.height - titleSize.height/2));
        this->addChild(getLabelTitle());
    }
    
    CCAction* popupLayerAction = CCSequence::create(CCScaleTo::create(0.0, 0.0),
                                              CCScaleTo::create(0.06, 1.05),
                                              CCScaleTo::create(0.08, 0.95),
                                              CCScaleTo::create(0.08, 1.0), NULL);
    this->runAction(popupLayerAction);
    
}
Beispiel #17
0
CCTableViewCell* MailListScene::tableCellAtIndex(CCTableView *table, unsigned int idx)
{
	CCString *string = (CCString *)mArrayList->objectAtIndex(idx);
    CCSize size = this->tableCellSizeForIndex(table, idx);
	CCTableViewCell *cell = table->dequeueCell();
	if (!cell) {
		cell = new CCTableViewCell();
		cell->autorelease();

		CCSprite *sState = CCSprite::createWithSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("mail_state_read.png"));
		sState->setAnchorPoint(CCPointMake(0, 0.5));
		sState->setPosition(ccp(10,size.height * 0.5));
		sState->setTag(120);
		cell->addChild(sState);

		CCLabelTTF *lblName = CCLabelTTF::create(string->getCString(), "Arial", 14.0);
		lblName->setPosition(ccp(65,size.height * 0.5));
        lblName->setColor(ccc3(255, 255, 204));
        //lblName->enableStroke(ccc3(51, 0, 0), 0.6);
		lblName->setTag(121);
		lblName->setHorizontalAlignment(kCCTextAlignmentLeft);
        lblName->setString(string->getCString());
		cell->addChild(lblName);

		CCLabelTTF *lblSubject = CCLabelTTF::create("100", "Arial", 14.0);
		lblSubject->setPosition(ccp(130,size.height * 0.5));
        lblSubject->setColor(ccc3(255, 255, 204));
        //lblSubject->enableStroke(ccc3(51, 0, 0), 0.6);
        lblSubject->setTag(122);
        lblSubject->setString(string->getCString());
		cell->addChild(lblSubject);
        
        CCScale9Sprite *sline = CCScale9Sprite::createWithSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("mail_line.png"));
        sline->setPreferredSize(CCSizeMake(310, 1));
        sline->setPosition(ccp(0,size.height-2));
        sline->setAnchorPoint(CCPointZero);
        cell->addChild(sline);
        
        CCMenu *menuCheck = this->generateCheckBox();
        cell->addChild(menuCheck);
        CCMenuItemToggle *toggle= (CCMenuItemToggle *)menuCheck->getChildByTag(1);
        toggle->setUserData(&vUserData[idx]);
		if (vUserData[idx] == 1) {
			toggle->setSelectedIndex(1);
		} else {
			toggle->setSelectedIndex(0);
		}

        menuCheck->setTag(123);
        menuCheck->setAnchorPoint(CCPointMake(0, 0.5));
        menuCheck->setPosition(CCPointMake(280, size.height * 0.5));
	}
	else
	{
		CCLabelTTF *lblName = (CCLabelTTF*)cell->getChildByTag(121);
		lblName->setString(string->getCString());
        
        CCLabelTTF *lblSubject = (CCLabelTTF*)cell->getChildByTag(122);
		lblSubject->setString(string->getCString());
        
        CCMenu *menuCheck = (CCMenu *)cell->getChildByTag(123);
        CCMenuItemToggle *toggle= (CCMenuItemToggle *)menuCheck->getChildByTag(1);
		toggle->setUserData(&vUserData[idx]);

        if (vUserData[idx] == 1) {
			toggle->setSelectedIndex(1);
        } else {
            toggle->setSelectedIndex(0);
        }
	}

	return cell;
}
void SGEquipStrengLayer::initView()
{

    ResourceManager::sharedInstance()->bindTexture("sgequipslayer/sgequipslayer.plist", RES_TYPE_LAYER_UI, sg_equipstrengLayer);
    ResourceManager::sharedInstance()->bindTexture("animationFile/qhtexiao.plist", RES_TYPE_LAYER_UI, sg_equipstrengLayer);
    ResourceManager::sharedInstance()->bindTexture("animationFile/wjzs.plist", RES_TYPE_LAYER_UI, sg_equipstrengLayer);
    ResourceManager::sharedInstance()->bindTexture("sgpropslayer/sgpropslayer.plist", RES_TYPE_LAYER_UI, sg_equipstrengLayer);
    ResourceManager::sharedInstance()->bindTexture("sgvipinfolayer/sgvipinfolayer.plist", RES_TYPE_LAYER_UI, sg_equipstrengLayer); //提供横条图
    ResourceManager::sharedInstance()->bindTexture("sggeneralinfolayer/ofcNewUi.plist", RES_TYPE_LAYER_UI, sg_equipstrengLayer);

    SGNotificationCenter *notification = SGNotificationCenter::sharedNotificationCenter();
    notification->addObserver(MSG_EQUIP_NEWSTRENG,
                              this,
                              callfuncO_selector(SGEquipStrengLayer::equipStrenghListener));
    notification->addObserver(MSG_EQUIP_NEWAUTOSTRENG,
                              this,
                              callfuncO_selector(SGEquipStrengLayer::autoEquipStrenghListener));
	if (CCEGLView::sharedOpenGLView()->getFrameSize().width == ipadResource.size.width
        ||CCEGLView::sharedOpenGLView()->getFrameSize().width == ipadhdResource.size.width)
	{
		adpt_wid = -40;
		adpt_hei = -20;
		shift_ipad = 70;
	}
	else if (CCEGLView::sharedOpenGLView()->getFrameSize().height == iphonehdResource.size.height
             ||CCEGLView::sharedOpenGLView()->getFrameSize().height == iphoneResource.size.height)
	{
        adpt_wid = -10;
		adpt_hei = -50;
	}
    else
    {
        adpt_wid = -20;
		adpt_hei = -50;
    }
    
    CCSize winSize = CCDirector::sharedDirector()->getWinSize();
    float btmheight = SGMainManager::shareMain()->getBottomHeight();
    float frameheight1 = skewingY(81);
    float hgt=skewingY(233);
    menu->setZOrder(10);
    if (winSize.height == 1136)
    {
        frameheight1 = skewing(81);
        hgt = skewing(233);
    }
    
    //左火
    CCSpriterX *fermEffect = CCSpriterX::create("animationFile/qhhyA.scml", true, true);
    fermEffect->setanimaID(0);
    fermEffect->setisloop(true);
    addChild(fermEffect, 10, 0);
    //右火
    CCSpriterX *fermEffect1 = CCSpriterX::create("animationFile/qhhyB.scml", true, true);
    fermEffect1->setCCSpriterXFlipX(true);
    fermEffect1->setanimaID(0);
    fermEffect1->setisloop(true);
    addChild(fermEffect1, 10, 1);
    
	SGEquipmentDataModel *temp = SGStaticDataManager::shareStatic()->getEquipById(_card->getItemId());
	
    SGMainManager::shareMain()->addEquipPng(temp->getIconId(),sg_equipstrengLayer);
    CCString *str = CCString::createWithFormat("equip%d.png",temp->getIconId());
	
	
    CCSprite *item = CCSprite::createWithSpriteFrameName(str->getCString());
    this->addChild(item,2, 123);
    //创建4中颜色武将背景
    std::vector<std::string> str_vec;
    if(winSize.height != 1136)
    {
        str_vec.push_back("greenBg.png");
        str_vec.push_back("blueBg.png");
        str_vec.push_back("purpleBg.png");
        str_vec.push_back("orangeBg.png");
    }
    //inphone 5  根据武将地图来
    else
    {
        str_vec.push_back("greenBgI5.png");
        str_vec.push_back("blueBgI5.png");
        str_vec.push_back("purpleBgI5.png");
        str_vec.push_back("orangeBgI5.png");
    }
    int starLev = _card->getCurrStar();
    starLev = starLev<3?3:starLev;
    starLev = starLev>6?6:starLev;
    //光效背景图片
    CCSprite * lightBg = CCSprite::createWithSpriteFrameName(str_vec[starLev-3].c_str());
    this->addChild(lightBg , 0  , 1919);
    
    float adjustY = 0;
    CCSprite *bigbg = NULL;
    item->setAnchorPoint(ccp(0.5, 0));
    if (winSize.height == 960)
    {
        adjustY = 40;
        frameSize = CCRectMake(0, 0 , 768, 413);
        this->setItemID("pad装备底图.png",true);
        fermEffect->setScale(winSize.width/768);
        fermEffect1->setScale(winSize.width/768);
        fermEffect->setPosition(ccpAdd(SGLayout::getPoint(kUpCenter), ccp(-264, -287 +26)));
        fermEffect1->setPosition(ccpAdd(SGLayout::getPoint(kUpCenter), ccp(264, -287 +26)));
        item->setPosition(ccpAdd(SGLayout::getPoint(kUpCenter), ccp(0, -365)));
        
        lightBg->setZOrder(0);
        lightBg->setScaleX(winSize.width / lightBg->getContentSize().width);
        lightBg->setScaleY(1.6);
        lightBg->setPosition(ccpAdd(SGLayout::getPoint(kUpCenter),
                               ccp(0, -title_bg->getContentSize().height - lightBg->getContentSize().height*0.5*lightBg->getScaleY())));;
        
    }
    else if (winSize.height == 1136)
    {
        adjustY=31;
        
        frameSize = CCRectMake(0, 520 -(winSize.height - hgt*1.18 - title_bg->getContentSize().height), 768, (winSize.height - hgt*1.18 - title_bg->getContentSize().height));
        this->setItemID("carditembg.png",true);
        fermEffect->setScaleX(winSize.width/768);
        fermEffect1->setScaleX(winSize.width/768);
        fermEffect->setPosition(ccpAdd(SGLayout::getPoint(kUpCenter), ccp(-264, -361+26)));
        fermEffect1->setPosition(ccpAdd(SGLayout::getPoint(kUpCenter), ccp(264, -361+26)));
        
        item->setPosition(ccpAdd(SGLayout::getPoint(kUpCenter), ccp(0, -450)));
        
        CCSprite *temp = CCSprite::createWithSpriteFrameName("carditembg.png");
        lightBg->setScaleX(winSize.width / lightBg->getContentSize().width);
        lightBg->setScaleY(temp->getContentSize().height * 0.75 / lightBg->getContentSize().height);
        lightBg->setPosition(ccpAdd(SGLayout::getPoint(kUpCenter),
                               ccp(0, -title_bg->getContentSize().height - temp->getContentSize().height * 0.8 /2 + 16) ));
        
    }
    else
    {
        adjustY = 55;
        
        bigbg = CCSprite::createWithSpriteFrameName("pad装备底图.png");
        
        this->addChild(bigbg,-100);
        bigbg->setPosition(ccpAdd(SGLayout::getPoint(kUpCenter), ccp(0, - title_bg->getContentSize().height - bigbg->getContentSize().height*.45)));
        fermEffect->setPosition(ccpAdd(bigbg->getPosition(), ccp(-bigbg->getContentSize().width*.41, bigbg->getContentSize().height*.02 -bigbg->getContentSize().height*.098)));
        fermEffect1->setPosition(ccpAdd(bigbg->getPosition(), ccp(bigbg->getContentSize().width*.41, bigbg->getContentSize().height*.02-bigbg->getContentSize().height*.098)));
        
        item->setPosition(ccpAdd(bigbg->getPosition(), ccp(0, -bigbg->getContentSize().height*.362)));
        
        lightBg->setScaleX(winSize.width / lightBg->getContentSize().width);
        lightBg->setScaleY(1.9);
        lightBg->setPosition(ccpAdd(SGLayout::getPoint(kUpCenter),
                               ccp(0, -title_bg->getContentSize().height-5 - lightBg->getContentSize().height*0.5*lightBg->getScaleY())));
    }
    equipItem = item;
    fermEffect->play();
    fermEffect1->play();
    
    this->setstar(_card->getCurrStar(),_card->getUpgradestar());
    this->setTitle(str_zhuangbeiqianghua);//_card->getOfficerName()->getCString()

    //////////////////////
    
    float btnwidth = skewing(5);
    float btnwid = skewing(33);
    
    equipStrengBtn = SGButton::createFromLocal(IMG_BTN_ON, str_qianghua_, this, menu_selector(SGEquipStrengLayer::equipStrengHandler),CCPointZero,FONT_PANGWA,ccWHITE,32,false,true);
    this->addBtn(equipStrengBtn);
    if(winSize.height==1136)
        equipStrengBtn->setPosition(ccp(winSize.width/2- btnwid*3 - btnwidth - adpt_wid, btmheight*.55 + equipStrengBtn->getContentSize().height*0.7+ adjustY*0.6));
    else if (winSize.height == 1024)
        equipStrengBtn->setPosition(ccp(winSize.width/2- btnwid*3 - btnwidth - adpt_wid, btmheight*.55 + equipStrengBtn->getContentSize().height*0.7));
    else
        equipStrengBtn->setPosition(ccp(winSize.width/2- btnwid*3 - btnwidth - adpt_wid, btmheight*.55 + equipStrengBtn->getContentSize().height*0.7 + 10));
    
    equipAutoStrengBtn = SGButton::createFromLocal(IMG_BTN_ON, str_autoqianghua, this, menu_selector(SGEquipStrengLayer::autoEquipStrengHandler),CCPointZero,FONT_PANGWA,ccWHITE,32,false,true);
    this->addBtn(equipAutoStrengBtn);
    equipAutoStrengBtn->setPosition(ccpAdd(equipStrengBtn->getPosition(), ccp( equipAutoStrengBtn->getContentSize().width - adpt_wid,0 )));
    
    int limittag = SGStaticDataManager::shareStatic()->getimitTagById(limitEquipGuide,9);
    equipAutoStrengBtn->setTag(limittag);
    
    SGButton *backBtn = SGButton::createFromLocal(IMG_BTN_ON, str_Back_, this, menu_selector(SGEquipStrengLayer::backHandler),CCPointZero,FONT_PANGWA,ccWHITE,32);
	backBtn->setScale(1.05);
    this->addBtn(backBtn);
    backBtn->setPosition(ccpAdd(equipAutoStrengBtn->getPosition(), ccp( backBtn->getContentSize().width - adpt_wid,0)));
    
    
    SGEquipmentDataModel *general = SGStaticDataManager::shareStatic()->getEquipById(_card->getItemId());
    this->setCardType(general->getEquipType());
    
 
    ////////////////////////
    
    float bigFrmWidth = winSize.width - 40;
    float bigFrmHeight = (int)winSize.height/3 -20;
    
    CCScale9Sprite *bigFrm = CCScale9Sprite::createWithSpriteFrameName("barrack_kuang.png");
    bigFrm->setPreferredSize(CCSizeMake(bigFrmWidth, bigFrmHeight));
    this->addChild(bigFrm,7);
    if(winSize.height==1136)
        bigFrm->setPosition(ccpAdd(ccp(winSize.width/2,equipStrengBtn->getPosition().y), ccp(0, equipStrengBtn->getContentSize().height/2 + bigFrmHeight/2 + 4 + adjustY*0.6)));
    else if(winSize.height==1024)
        bigFrm->setPosition(ccpAdd(ccp(winSize.width/2,equipStrengBtn->getPosition().y), ccp(0, equipStrengBtn->getContentSize().height/2 + bigFrmHeight/2 + 4)));
    else
        bigFrm->setPosition(ccpAdd(ccp(winSize.width/2,equipStrengBtn->getPosition().y), ccp(0, equipStrengBtn->getContentSize().height/2 + bigFrmHeight/2 + 10 )));
    
    CCSprite *bigFrmBg = CCSprite::createWithSpriteFrameName("barrack_kuangbg.png");
    this->addChild(bigFrmBg,6);
    bigFrmBg->setScaleX(bigFrmWidth/bigFrmBg->getContentSize().width);
    bigFrmBg->setScaleY(bigFrmHeight/bigFrmBg->getContentSize().height);
    bigFrmBg->setPosition(bigFrm->getPosition());
    
    CCSprite* admsBkg = CCSprite::createWithSpriteFrameName("store_redbg.png");
    float scaleX = winSize.width / admsBkg->getContentSize().height;
    float scaleY = 60 / admsBkg->getContentSize().height;
    admsBkg->setScaleX(scaleX);
    admsBkg->setScaleY(scaleY);
    this->addChild(admsBkg, 9);
//    admsBkg->setPosition(ccpAdd(bigFrm->getPosition(), ccp(0,admsBkg->getContentSize().height*scaleY/2 + bigFrm->getContentSize().height/2) ));
    
    admsBkg->setPosition(ccpAdd(lightBg->getPosition(), ccp(0, -lightBg->getScaleY() *lightBg->getContentSize().height*0.5 - admsBkg->getContentSize().height*0.5*lightBg->getScaleY() + adjustY)) );
    /////////////////////////////////
    
    equipName = SGCCLabelTTF::create(_card->getOfficerName()->getCString(), FONT_PANGWA, 26);
    equipName->setPosition(ccpAdd(bigFrm->getPosition(), ccp(-40,bigFrm->getContentSize().height/2 - 26 )));
    int equipStar = _card->getCurrStar() - 2;
    equipStar = equipStar < 0 ? 0 : equipStar;
    if (equipStar >= 0 && equipStar < 5) {
        equipName->setInsideColor(ccStarLevelColor[equipStar]);
    }
    else
    {
        equipName->setInsideColor(ccWHITE);
    }
    addChild(equipName,11);
    
    equiplevel = SGCCLabelTTF::create(CCString::createWithFormat("Lv %d/%d",_card->getCurrLevel(),SGPlayerInfo::sharePlayerInfo()->getPlayerLevel())->getCString(), FONT_PANGWA, 26);
    addChild(equiplevel,11);
    equiplevel->setPosition(ccpAdd(equipName->getPosition(), ccp(equipName->getContentSize().width/2 + equiplevel->getContentSize().width/2 + 20,0)));
    
    ///////////////////////////
    
    SGCCLabelTTF *costMoney = SGCCLabelTTF::create(str_zbqianghuancost, FONT_PANGWA, 24 , COLOR_UNKNOW_TAN);
    this->addChild(costMoney,11);
    costMoney->setPosition( ccp(costMoney->getContentSize().width/2 +20, admsBkg->getPosition().y));
    
    SGCCLabelTTF *totalMoney = SGCCLabelTTF::create(str_zbqianghuantotalMy, FONT_PANGWA, 24 , COLOR_UNKNOW_TAN);
    this->addChild(totalMoney,11);
    totalMoney->setPosition( ccp(winSize.width/2 + totalMoney->getContentSize().width/2 + 10 , costMoney->getPosition().y));
    
    CCSprite *font_bg = CCSprite::createWithSpriteFrameName(FONTBG);
    font_bg->setScaleY(1.4);
    this->addChild(font_bg,9);
    font_bg->setPosition(ccpAdd(costMoney->getPosition(),  ccp(costMoney->getContentSize().width/2 + font_bg->getContentSize().width/2+ 6,0)));
    
    font_bg = CCSprite::createWithSpriteFrameName(FONTBG);
    font_bg->setScaleY(1.4);
    this->addChild(font_bg,9);
    font_bg->setPosition(ccpAdd(totalMoney->getPosition(),  ccp(totalMoney->getContentSize().width/2 + font_bg->getContentSize().width/2+6,0)));
    
    CCSprite *coins = CCSprite::createWithSpriteFrameName("coinicon.png");
    coins->setPosition(ccpAdd(costMoney->getPosition(),ccp(costMoney->getContentSize().width/2 +coins->getContentSize().width/2+4,0)));
    addChild(coins,11);
    
    costCount = SGCCLabelTTF::create("999999", FONT_PANGWA, 24);
    costCount->setPosition(ccpAdd(coins->getPosition(),ccp(coins->getContentSize().width/2+costCount->getContentSize().width/2+8,0)));
    addChild(costCount,11);
    
    coins = CCSprite::createWithSpriteFrameName("coinicon.png");
    coins->setPosition(ccpAdd(totalMoney->getPosition(),ccp(totalMoney->getContentSize().width /2+coins->getContentSize().width/2+4,0)));
    addChild(coins,11);
    
    totalCount = SGCCLabelTTF::create("999999", FONT_PANGWA, 24);
    totalCount->setPosition(ccpAdd(coins->getPosition(),ccp(coins->getContentSize().width/2+totalCount->getContentSize().width/2 +8,0)));
    addChild(totalCount,11);
    
    /////////////////////////////////
    
    float f1Height = (int)bigFrmHeight*2/3;
    float f1Width = (int)f1Height* 0.85;
    
    CCScale9Sprite *frame1 = CCScale9Sprite::createWithSpriteFrameName(STATUSBG);
    frame1->setPreferredSize(CCSizeMake(f1Width, f1Height));
    this->addChild(frame1,11);
    frame1->setPosition(ccp(40 + f1Width/2, bigFrm->getPosition().y - 30));
    
    CCScale9Sprite *frame2 = CCScale9Sprite::createWithSpriteFrameName(STATUSBG);
    frame2->setPreferredSize(CCSizeMake(f1Width, f1Height));
    this->addChild(frame2,11);
    frame2->setPosition( ccp(winSize.width - frame1->getPosition().x, frame1->getPosition().y));
    
    
    SGCCLabelTTF *currentTitle = SGCCLabelTTF::create(str_zbqianghuacurstatus, FONT_PANGWA, 32);
    this->addChild(currentTitle,11);
    currentTitle->setPosition( ccp(frame1->getPosition().x, frame1->getPosition().y + frame1->getContentSize().height/2 + 30));

    SGCCLabelTTF *nextTitle = SGCCLabelTTF::create(str_zbqianghuanextstatus, FONT_PANGWA, 32 , ccGREEN);
    this->addChild(nextTitle,11);
    nextTitle->setPosition( ccp(frame2->getPosition().x, currentTitle->getPosition().y));
    //modify by:zyc. merge into create.
    //nextTitle->setColor(ccGREEN);
    
 
    CCSprite *equipArrow = CCSprite::createWithSpriteFrameName("equipArrow.png");
    this->addChild(equipArrow,20);
    equipArrow->setPosition(ccp(SGLayout::getPoint(kMiddleCenter).x, frame1->getPosition().y));

    this->addCurrStatus( ccpAdd(frame1->getPosition(),ccp( -f1Width/2,f1Height/2)),f1Width * 0.4,1.4*winSize.height/1140);
    this->addNextStatus( ccpAdd(frame2->getPosition(),ccp( -f1Width/2,f1Height/2)),f1Width * 0.4,1.4*winSize.height/1140);
    
    
    setEquipLevel(_card->getCurrLevel());
    setCostCount(_card->getCurrLevel());
    setCurrStatus(_card->getCurrLevel());

    creatBostLevel(SGLayout::getPoint(kMiddleCenter));
    
    showMainChat(false);
    
}
void QuestionLayer::startAnswer()
{
    timerCount = timerTotal;

    CCSize size = this->getContentSize();
    CCLOG("%f %f", size.width, size.height);

    CCScale9Sprite* labelBg = CCScale9Sprite::create("bg_question.png");
    labelBg->setAnchorPoint(ccp(0.5, 0.5));
    labelBg->setPosition(ccp(0, size.height/2-100));
    labelBg->setContentSize(CCSizeMake(size.width, 160));
    this->addChild(labelBg, 0);

    const char* filePath = NULL;
    if (queType == SingleQuestion) {
        filePath = CCFileUtils::sharedFileUtils()->fullPathForFilename("question_4.plist").c_str();
    } else if (queType == JudgeQuestion) {
        filePath = CCFileUtils::sharedFileUtils()->fullPathForFilename("question_2.plist").c_str();
    } else {
        filePath = CCFileUtils::sharedFileUtils()->fullPathForFilename("question_3.plist").c_str();
    }
    CCArray* plistArray = CCArray::createWithContentsOfFile(filePath);
    //开始查找随机题目,并且不能重复
    bool bFind = false;
    while (!bFind) {
        serialNo = arc4random()%plistArray->count(); //serialNo = CCRANDOM_0_1()*plistArray->count()-1;
        CCLOG("serialNo:%d", serialNo);
        bool isSame = false;
        for (int i=0; i<historyQuestiones->count(); i++) {
            CCInteger* integer = (CCInteger *)historyQuestiones->objectAtIndex(i);
            if (integer->getValue() == serialNo) {
                isSame = true;
                break;
            }
        }
        if (!isSame) {
            bFind = true;
        }
    }
    historyQuestiones->addObject(CCInteger::create(serialNo));

    CCDictionary* dic = (CCDictionary*)plistArray->objectAtIndex(serialNo);
    CCString* qType = (CCString *)(dic->objectForKey("type")); //Number类型
    CCString* pStr = (CCString *)(dic->objectForKey("question"));
    CCLOG("%d %s", qType->intValue(), pStr->getCString());
    CCArray* ans = (CCArray *)(dic->objectForKey("answer"));

    questionObj = new QuestionObj(qType->intValue(), pStr->getCString(), ans);
    CCLOG("读取题目信息完成");

    questionString = questionObj->questionString;
    displayLen = 0;
    //题目
    CCLabelTTF* pLabel = CCLabelTTF::create(questionStr.c_str(), "Arial", 24, CCSize(size.width-20, 90), kCCTextAlignmentLeft, kCCVerticalTextAlignmentTop);
    pLabel->setAnchorPoint(ccp(1, 0));
    pLabel->setPosition(ccp(-size.width/2+15, size.height/2-130));
    pLabel->setAnchorPoint(ccp(0, 0));
    this->addChild(pLabel, 1, 11);

    const char* typeStr = "单选题";
    if (questionObj->questionType == 1) {
        typeStr = "单选题";
        timerTotal = 15;
    } else if (questionObj->questionType == 2) {
        typeStr = "判断题";
        timerTotal = 12;
    } else {
        typeStr = "多选题";
        timerTotal = 30;
    }
    CCString* title = CCString::createWithFormat("题型:%s", typeStr);
    CCLabelTTF* label = CCLabelTTF::create(title->getCString(), "Arial", 24);
    label->setAnchorPoint(ccp(0, 1));
    label->setPosition(ccp(140, size.height/2-135));
    this->addChild(label, 1, 12);

//    CCSprite* timerBg = CCSprite::create("money_bg.png");
//    timerBg->setPosition(ccp(0, size.height/2-200));
//    this->addChild(timerBg);
    progressTimer = CCProgressTimer::create(CCSprite::create("money_bg.png"));
    progressTimer->setType(kCCProgressTimerTypeBar);
    progressTimer->setMidpoint(ccp(0, 0));
    progressTimer->setBarChangeRate(ccp(1, 0));
    progressTimer->setAnchorPoint(ccp(0.5, 0.5));
    progressTimer->setPosition(ccp(0, size.height/2-200));
    progressTimer->setPercentage(100);
    progressTimer->setContentSize(CCSizeMake(300, 38));
    this->addChild(progressTimer, 2);
    timerLabel_ = CCLabelTTF::create(CCString::createWithFormat("%d", timerCount)->getCString(), "Arial", 24);
    timerLabel_->setAnchorPoint(ccp(1, 0));
    timerLabel_->setPosition(ccp(0, 0));
    progressTimer->addChild(timerLabel_);
    warnTipSpr = CCSprite::create("arrow000.png");
    warnTipSpr->setPosition( ccp(progressTimer->getContentSize().width/3*2, 0) );
    warnTipSpr->setAnchorPoint( ccp(0.5, 0) );
    progressTimer->addChild(warnTipSpr);

    //显示宫格答案
    this->displaySubViews();

    this->schedule(schedule_selector(QuestionLayer::displayActionTimerCB), 0.05f);

    isAnswerFinished = false;
    //
    serialNo++;
    if (serialNo > plistArray->count()-1) {
        serialNo = 0;
    }

    propLayer_ = FightPropLayer::create();
    propLayer_->setDelegate(this);
    propLayer_->setAnchorPoint( ccp(0.5, 0.5) );
    propLayer_->setPosition( ccp(-size.width/2, -size.height/2) );
    this->addChild(propLayer_, 100, 100);
}
void ArenaWindow::recv_3700()
{
    Message *revMsg=(Message *)CData::getCData()->m_dictionary->objectForKey(3700);
    CData::getCData()->m_dictionary->removeObjectForKey(3700);
    
    
    if(revMsg)
    {
        load->removeFromParent();
        
        this->unschedule(schedule_selector(ArenaWindow::recv_3700));
        char* data=revMsg->data;
        CCLog("%s",data);
        Json::Reader read;
        Json::Value root;
        Json::Value jsonData;
        Json::Value petlist;
        
        
        if(read.parse(data, root)){
            
            CCSprite* sp = CCSprite::create();
            
            jsonData=root["data"];
            petlist=jsonData["dsList"];
            
            int sptimes = jsonData["sptimes"].asInt();
            
            char titlechar[100] = "";
            sprintf(titlechar, "当前排名:%d  今日挑战剩余次数:%d",jsonData["ranking"].asInt(),jsonData["sptimes"].asInt());
            CCLabelTTF* titel = CCLabelTTF::create(titlechar, "hycc.ttf", 22,CCSizeMake(400, 0),kCCTextAlignmentCenter);
            titel->setColor(ccc3(255, 219, 160));
            titel->setPosition(ccp(size.width/2, 600));
            this->addChild(titel);
            
            int len = petlist.size();
            
            for (int i=0; i<len; i++) {
                
                CCScale9Sprite* item = CCScale9Sprite::create("arena_item_bkg.png");
                item->setContentSize(CCSizeMake(410, 85));
                char rank[10] = "";
                sprintf(rank, "%d",jsonData["dsList"][i]["ranking"].asInt());
                CCLabelTTF* ranking = CCLabelTTF::create(rank, "hycc.ttf", 20,CCSizeMake(200, 0),kCCTextAlignmentCenter);
                //ranking->setColor(ccc3(255, 219, 160));
                ranking->setPosition(ccp(37, 42));
                item->addChild(ranking);
                
                CCLabelTTF* nickname = CCLabelTTF::create(jsonData["dsList"][i]["nickname"].asString().c_str(), "hycc.ttf", 18,CCSizeMake(200, 0),kCCTextAlignmentLeft);
                nickname->setColor(ccc3(255, 219, 160));
                nickname->setAnchorPoint(ccp(0, 0));
                nickname->setPosition(ccp(85, 30));
                item->addChild(nickname);
                
                char levelchar[10] = "";
                sprintf(levelchar, "%d级",jsonData["dsList"][i]["level"].asInt());
                CCLabelTTF* level = CCLabelTTF::create(levelchar, "hycc.ttf", 18,CCSizeMake(200, 0),kCCTextAlignmentLeft);
                level->setAnchorPoint(ccp(0, 0));
                level->setColor(ccc3(255, 219, 160));
                level->setPosition(ccp(180, 30));
                item->addChild(level);
                
                if (sptimes != 0) {
                    CCMenuItemImage* ok = CCMenuItemImage::create("arena_btn_bat_1.png", "arena_btn_bat_2.png", this, menu_selector(ArenaWindow::clk_battle));
                    ok->setTag(jsonData["dsList"][i]["characterId"].asInt());
                    CCMenu* menu = CCMenu::create();
                    menu->setAnchorPoint(ccp(0, 0));
                    menu->setPosition(ccp(370, 40));
                    menu->addChild(ok);
                    item->addChild(menu);
                }
                
                
                CCSprite* qsbkg = CCSprite::create("common_qs_bkg_4.png");
                qsbkg->setScale(1.0);
                
                int pro = jsonData["dsList"][i]["profession"].asInt();
                
                char prochar[20] = "";
                sprintf(prochar, "qs_%04d.png",pro);
                
                CCSprite* headsp = CCSprite::create(prochar);
                headsp->setScale(0.18);
                headsp->setAnchorPoint(ccp(0, 0));
                qsbkg->addChild(headsp);
                
                qsbkg->setPosition(ccp(265, 38));
                item->addChild(qsbkg);
                
                
                
                item->setAnchorPoint(ccp(0.5, 1));
                item->setPosition(ccp(0,-i*82));//82
                sp->addChild(item);

            }
            sp->setPosition(ccp(size.width/2, 560));
            this->addChild(sp);
        }
    }

}
Beispiel #21
0
bool HelpLayer::init(){
	//////////////////////////////
	// 1. super init first
	if (!CCLayer::init()){
		return false;
	}
	CCScale9Sprite *pBackground = CCScale9Sprite::create("Dialog_bg.png");

	pBackground->setAnchorPoint(ccp(0.5f,0.5f));
	CCSize frameSize = CCEGLView::sharedOpenGLView()->getFrameSize();
	float scale = frameSize.width / DESIGN_WIDTH;
	float newScaleY = 1.0f;
	if (scale > 0){
		float scaleY = frameSize.height / DESIGN_HEIGHT;
		if (scaleY > scale){
			newScaleY = scaleY / scale;
		}		
	}	
	pBackground->setPreferredSize(CCSizeMake(DESIGN_WIDTH - 20,(DESIGN_HEIGHT - 130) * newScaleY));
	CCSize size = pBackground->getContentSize();
	pBackground->setPosition(VisibleRect::center());
	addChild(pBackground);

	CCSprite *pTitleBgSp = CCSprite::create("Dialog_Title.png");
	pTitleBgSp->setPosition(ccp(pBackground->getPositionX(),pBackground->getPositionY() + pBackground->getContentSize().height / 2));
	addChild(pTitleBgSp);

	CCSprite *pTitleSp = CCSprite::create("Title_Help.png");
	pTitleSp->setPosition(ccp(pTitleBgSp->getPositionX(),pTitleBgSp->getPositionY() + pTitleSp->getContentSize().height / 2 + 5));
	addChild(pTitleSp);

	CCSprite *pItemNormal = CCSprite::create("cancel_s.png");
	CCSprite *pItemSelected = CCSprite::create("cancel_s.png");
	CCMenuItem *pClose = CCMenuItemSprite::create(pItemNormal, pItemSelected, this, menu_selector(HelpLayer::close));
	pClose->setPosition(ccp(pTitleSp->getPositionX() + pTitleSp->getContentSize().width * 3 / 2, pTitleSp->getPositionY()));
	pItemSelected->setScale(1.1f);
	pItemSelected->setAnchorPoint(ccp(0.05f, 0.05f));

	CCMenu *pMenu = CCMenu::create(pClose, NULL);
	pMenu->setPosition(CCPointZero);
	addChild(pMenu, 1);
	CCDictionary *text = CCDictionary::createWithContentsOfFile(XML_DATA);
	CCString *msg = (CCString*)text->objectForKey("rule");
	CCLabelTTF *msgLabel = CCLabelTTF::create(msg->getCString(), "Arial", 21,CCSizeMake(DESIGN_WIDTH - 40, 0),kCCTextAlignmentLeft);
	msgLabel->setColor(ccc3(0,0,0));
	msgLabel->setPosition(ccp(pTitleBgSp->getPositionX(),pTitleBgSp->getPositionY() - pTitleBgSp->getContentSize().height / 2 - msgLabel->getContentSize().height / 2 - 5));
	addChild(msgLabel);

	CCSprite *phSp = CCSprite::create("Help_1.png");
	phSp->setPosition(ccp(msgLabel->getPositionX(),msgLabel->getPositionY() - msgLabel->getContentSize().height / 2 - phSp->getContentSize().height / 2 - 3));
	addChild(phSp);

	msg = (CCString*)text->objectForKey("scoreTips");
	msgLabel = CCLabelTTF::create(msg->getCString(), "Arial", 21,CCSizeMake(DESIGN_WIDTH - 40, 0),kCCTextAlignmentCenter);
	msgLabel->setColor(ccc3(0,0,0));
	msgLabel->setPosition(ccp(phSp->getPositionX(),phSp->getPositionY() - phSp->getContentSize().height / 2 - msgLabel->getContentSize().height / 2 - 10));
	addChild(msgLabel);

	phSp = CCSprite::create("Help_2.png");
	phSp->setPosition(ccp(msgLabel->getPositionX(),msgLabel->getPositionY() - msgLabel->getContentSize().height / 2 - phSp->getContentSize().height / 2 - 3));
	addChild(phSp);

	msg = (CCString*)text->objectForKey("pro");
	msgLabel = CCLabelTTF::create(msg->getCString(), "Arial", 21,CCSizeMake(DESIGN_WIDTH - 40, 0),kCCTextAlignmentLeft);
	msgLabel->setColor(ccc3(0,0,0));
	msgLabel->setPosition(ccp(pBackground->getPositionX() - pBackground->getContentSize().width / 2 + msgLabel->getContentSize().width / 2 + 10,
		phSp->getPositionY() - phSp->getContentSize().height / 2 - msgLabel->getContentSize().height / 2 - 3));
	addChild(msgLabel);

	CCSprite* bombSp = CCSprite::create("Props_Bomb.png");
	bombSp->setPosition(ccp(pBackground->getPositionX() - pBackground->getContentSize().width / 2 + bombSp->getContentSize().width / 2 + 10,
		msgLabel->getPositionY() - msgLabel->getContentSize().height / 2 - bombSp->getContentSize().height / 2 - 3));
	addChild(bombSp);

	msg = (CCString*)text->objectForKey("bomb");
	msgLabel = CCLabelTTF::create(msg->getCString(), "Arial", 18,CCSizeMake(DESIGN_WIDTH - 40, 0),kCCTextAlignmentLeft);
	msgLabel->setColor(ccc3(0,0,0));
	msgLabel->setPosition(ccp(bombSp->getPositionX() + bombSp->getContentSize().width / 2 + msgLabel->getContentSize().width / 2 + 5,
		bombSp->getPositionY() + 13));
	addChild(msgLabel);

	msg = (CCString*)text->objectForKey("useCoin");
	CCString *showUseString = CCString::createWithFormat(msg->getCString(),GameData::getInstance()->m_nBombUseCoin);
	CCLabelTTF *showUseLabel = CCLabelTTF::create(showUseString->getCString(), "Arial", 14,CCSizeMake(DESIGN_WIDTH - 40, 0),kCCTextAlignmentLeft);
	showUseLabel->setColor(ccc3(0,0,0));
	showUseLabel->setPosition(ccp(bombSp->getPositionX() + bombSp->getContentSize().width / 2 + showUseLabel->getContentSize().width / 2 + 5,
		msgLabel->getPositionY() - msgLabel->getContentSize().height / 2 - showUseLabel->getContentSize().height / 2 - 2));
	addChild(showUseLabel);

	CCSprite *paintSp = CCSprite::create("Props_Paint.png");
	paintSp->setPosition(ccp(pBackground->getPositionX() - pBackground->getContentSize().width / 2 + paintSp->getContentSize().width / 2 + 10,
		bombSp->getPositionY() - bombSp->getContentSize().height / 2 - paintSp->getContentSize().height / 2 - 10));
	addChild(paintSp);

	msg = (CCString*)text->objectForKey("shua");
	msgLabel = CCLabelTTF::create(msg->getCString(), "Arial", 18,CCSizeMake(DESIGN_WIDTH - 40, 0),kCCTextAlignmentLeft);
	msgLabel->setColor(ccc3(0,0,0));
	msgLabel->setPosition(ccp(paintSp->getPositionX() + paintSp->getContentSize().width / 2 + msgLabel->getContentSize().width / 2 + 5,
		paintSp->getPositionY() + 13));
	addChild(msgLabel);
	
	msg = (CCString*)text->objectForKey("useCoin");
	showUseString = CCString::createWithFormat(msg->getCString(),GameData::getInstance()->m_nPaintUseCoin);
	showUseLabel = CCLabelTTF::create(showUseString->getCString(), "Arial", 14,CCSizeMake(DESIGN_WIDTH - 40, 0),kCCTextAlignmentLeft);
	showUseLabel->setColor(ccc3(0,0,0));
	showUseLabel->setPosition(ccp(paintSp->getPositionX() + paintSp->getContentSize().width / 2 + showUseLabel->getContentSize().width / 2 + 5,
		msgLabel->getPositionY() - msgLabel->getContentSize().height / 2 - showUseLabel->getContentSize().height / 2 - 2));
	addChild(showUseLabel);

	CCSprite *rainSp = CCSprite::create("Props_Rainbow.png");
	rainSp->setPosition(ccp(pBackground->getPositionX() - pBackground->getContentSize().width / 2 + rainSp->getContentSize().width / 2 + 10,
		paintSp->getPositionY() - paintSp->getContentSize().height / 2 - rainSp->getContentSize().height / 2 - 10));
	addChild(rainSp);

	msg = (CCString*)text->objectForKey("zhuan");
	msgLabel = CCLabelTTF::create(msg->getCString(), "Arial", 18,CCSizeMake(DESIGN_WIDTH - 40, 0),kCCTextAlignmentLeft);
	msgLabel->setColor(ccc3(0,0,0));
	msgLabel->setPosition(ccp(rainSp->getPositionX() + rainSp->getContentSize().width / 2 + msgLabel->getContentSize().width / 2 + 5,
		rainSp->getPositionY() + 13));
	addChild(msgLabel);

	msg = (CCString*)text->objectForKey("useCoin");
	showUseString = CCString::createWithFormat(msg->getCString(),GameData::getInstance()->m_nReflashUseCoin);
	showUseLabel = CCLabelTTF::create(showUseString->getCString(), "Arial", 14,CCSizeMake(DESIGN_WIDTH - 40, 0),kCCTextAlignmentLeft);
	showUseLabel->setColor(ccc3(0,0,0));
	showUseLabel->setPosition(ccp(rainSp->getPositionX() + rainSp->getContentSize().width / 2 + showUseLabel->getContentSize().width / 2 + 5,
		msgLabel->getPositionY() - msgLabel->getContentSize().height / 2 - showUseLabel->getContentSize().height / 2 - 2));
	addChild(showUseLabel);

	msg = (CCString*)text->objectForKey("quese");
	msgLabel = CCLabelTTF::create(msg->getCString(), "Arial", 21,CCSizeMake(DESIGN_WIDTH - 40, 0),kCCTextAlignmentLeft);
	msgLabel->setColor(ccc3(0,0,0));
	msgLabel->setPosition(ccp(pBackground->getPositionX() - pBackground->getContentSize().width / 2 + msgLabel->getContentSize().width / 2 + 10,
		rainSp->getPositionY() - rainSp->getContentSize().height / 2 - 25));
	addChild(msgLabel);
	
	msg = (CCString*)text->objectForKey("phone");
	showUseLabel = CCLabelTTF::create(msg->getCString(), "Arial", 21,CCSizeMake(DESIGN_WIDTH - 40, 0),kCCTextAlignmentLeft);
	showUseLabel->setColor(ccc3(0,0,0));
	showUseLabel->setPosition(ccp(pBackground->getPositionX() - pBackground->getContentSize().width / 2 + showUseLabel->getContentSize().width / 2 + 10,
		msgLabel->getPositionY() - msgLabel->getContentSize().height / 2 - showUseLabel->getContentSize().height / 2 - 2));
	addChild(showUseLabel);

	msg = (CCString*)text->objectForKey("qq");
	msgLabel = CCLabelTTF::create(msg->getCString(), "Arial", 21,CCSizeMake(DESIGN_WIDTH - 40, 0),kCCTextAlignmentLeft);
	msgLabel->setColor(ccc3(0,0,0));
	msgLabel->setPosition(ccp(pBackground->getPositionX() - pBackground->getContentSize().width / 2 + msgLabel->getContentSize().width / 2 + 10,
		showUseLabel->getPositionY() - showUseLabel->getContentSize().height / 2 - msgLabel->getContentSize().height / 2 - 2));
	addChild(msgLabel);

	setPosition(ccp(0, -0.5 * getContentSize().height));
	return true;
}
void SGConsumableInfoLayer::initView()
{
	
    ResourceManager::sharedInstance()->bindTexture("animationFile/qhtexiao.plist",RES_TYPE_LAYER_UI ,sg_comsumableInfoLayer);
    ResourceManager::sharedInstance()->bindTexture("sgequipslayer/sgequipslayer.plist",RES_TYPE_LAYER_UI ,sg_comsumableInfoLayer);
    ResourceManager::sharedInstance()->bindTexture("sggeneralinfolayer/sggeneralinfolayer1.plist",RES_TYPE_LAYER_UI ,sg_comsumableInfoLayer);
    ResourceManager::sharedInstance()->bindTexture("sgrewardlayer/sgrewardlayer2.plist",RES_TYPE_LAYER_UI ,sg_comsumableInfoLayer);
    ResourceManager::sharedInstance()->bindTexture("sgsoldierslayer/sgsoldierslayer.plist",RES_TYPE_LAYER_UI ,sg_comsumableInfoLayer, LIM_PNG_AS_PNG);
    ResourceManager::sharedInstance()->bindTexture("sgpropslayer/sgpropslayer.plist",RES_TYPE_LAYER_UI ,sg_comsumableInfoLayer);
	
    
    CCSize s = CCDirector::sharedDirector()->getWinSize();
    float btmheight = SGMainManager::shareMain()->getBottomHeight();
	
    //float frameheight = skewingY(155);
    float hgt = skewingY(244);
    if (s.height == 1136) {
        //frameheight = skewing(155);
        hgt = skewing(244);
    }
    
	
    //左火
    CCSpriterX *fermEffect = CCSpriterX::create("animationFile/qhhyA.scml", true, true);
    
    fermEffect->setanimaID(0);
    fermEffect->setisloop(true);
    addChild(fermEffect, 10, 0);
    //右火
    CCSpriterX *fermEffect1 = CCSpriterX::create("animationFile/qhhyB.scml", true, true);
    fermEffect1->setCCSpriterXFlipX(true);
    fermEffect1->setanimaID(0);
    fermEffect1->setisloop(true);
    addChild(fermEffect1, 10, 1);
    CCLOG("type%d",_card->getItemType());
	//    if (_card->getType()) {
	//        statements
	//    }
    SGMainManager::shareMain()->addPropPng(_card->getHeadSuffixNum(),sg_comsumableInfoLayer);
    CCString *str = CCString::createWithFormat("prop%d.png",_card->getHeadSuffixNum());
    CCSprite *item = CCSprite::createWithSpriteFrameName(str->getCString());
    this->addChild(item,2);
    item->setAnchorPoint(ccp(0.5, 0));
	
    if (s.height == 960) {
        frameSize = CCRectMake(0, 0 , 768, 413);
        this->setItemID("pad装备底图.png",true);
        fermEffect->setScale(s.width/768);
        fermEffect1->setScale(s.width/768);
		
        fermEffect->setPosition(ccpAdd(SGLayout::getPoint(kUpCenter), ccp(-264, -287+26)));
        fermEffect1->setPosition(ccpAdd(SGLayout::getPoint(kUpCenter), ccp(264, -287+26)));
        item->setPosition(ccpAdd(SGLayout::getPoint(kUpCenter), ccp(0, -365)));
		
	}
    else if (s.height == 1136) {
        frameSize = CCRectMake(0, 520 -(s.height - hgt*1.13 - title_bg->getContentSize().height), 768, (s.height - hgt*1.13 - title_bg->getContentSize().height));
        this->setItemID("carditembg.png",true);
		
        fermEffect->setScaleX(s.width/768);
        fermEffect1->setScaleX(s.width/768);
        fermEffect->setPosition(ccpAdd(SGLayout::getPoint(kUpCenter), ccp(-264, -361+26)));
        fermEffect1->setPosition(ccpAdd(SGLayout::getPoint(kUpCenter), ccp(264, -361+26)));
		
        item->setPosition(ccpAdd(SGLayout::getPoint(kUpCenter), ccp(0, -450)));
		
		
    }else
    {
        CCSprite *a = CCSprite::createWithSpriteFrameName("pad装备底图.png");
        this->addChild(a,-100);
        a->setPosition(ccpAdd(SGLayout::getPoint(kUpCenter), ccp(0, - title_bg->getContentSize().height - a->getContentSize().height*.45)));
        fermEffect->setPosition(ccpAdd(a->getPosition(), ccp(-a->getContentSize().width*.41, a->getContentSize().height*.02 -a->getContentSize().height*.09)));
        fermEffect1->setPosition(ccpAdd(a->getPosition(), ccp(a->getContentSize().width*.41, a->getContentSize().height*.02-a->getContentSize().height*.09)));
        
        item->setPosition(ccpAdd(a->getPosition(), ccp(0, -a->getContentSize().height*.362)));
    }
    fermEffect->play();
    fermEffect1->play();
    menu->setZOrder(7);
	
    this->setstar(_card->getCurrStar());
    this->setTitle(_card->getOfficerName()->getCString());

	SGButton *backBtn = SGButton::createFromLocal("store_exchangebtnbg.png", str_back,
                                                  this, menu_selector(SGConsumableInfoLayer::backHandler),CCPointZero,FONT_PANGWA,ccWHITE,32);
	backBtn->setScale(1.05);
    this->addBtn(backBtn);
    backBtn->setPosition(ccpAdd(SGLayout::getPoint(kUpLeft), ccp( backBtn->getContentSize().width*.55, - backBtn->getContentSize().height*.55)));
    
    
    if(enterType == 101)
    {
        ResourceManager::sharedInstance()->bindTexture("sanguobigpic/barrack_bg.plist", RES_TYPE_LAYER_UI, sg_comsumableInfoLayer);

        CCSprite *bg1 = CCSprite::create("storyBg.png");
        //CCRect r = CCRectMake(0, 1136/2 - (hgt*1.13)/2, s.width, hgt*1.13);
        
        //bg1->setTextureRect(r);
        bg1->setScaleY(s.height/2 / bg1->getContentSize().height);
        bg1->setScaleX(s.width / bg1->getContentSize().width);
        bg1->setAnchorPoint(ccp(0.5, 0));
        bg1->setPosition(SGLayout::getPoint(kBottomCenter));
        this->addChild(bg1,5);
    }
    else
    {
		CCSprite *bg1 = CCSprite::createWithSpriteFrameName("info_redbg.png");
		bg1->setAnchorPoint(ccp(0.5, 0));
		bg1->setScaleX(s.width/bg1->getContentSize().width);
		bg1->setScaleY((hgt*1.13-btmheight*.68)/bg1->getContentSize().height);
		bg1->setPosition(ccpAdd(SGLayout::getPoint(kBottomCenter), ccp(0, btmheight*.68 )));
		this->addChild(bg1,5);
    }
    
    CCSprite* jinbian = CCSprite::createWithSpriteFrameName("jinbian.png");
    jinbian->setPosition(ccp(s.width/2, hgt*1.13));
    jinbian->setScaleX(s.width/jinbian->getContentSize().width);
    this->addChild(jinbian,6);
    
    CCScale9Sprite *frame2 = CCScale9Sprite::createWithSpriteFrameName("barrack_kuang.png");
    frame2->setPreferredSize(CCSizeMake(568+20, 320));
    this->addChild(frame2,7);
    frame2->setPosition(ccpAdd(jinbian->getPosition(), ccp(0, -frame2->getContentSize().height/2 - 30)));
	
    CCSprite *frame2bg = CCSprite::createWithSpriteFrameName("barrack_kuangbg.png");
    this->addChild(frame2bg,6);
    frame2bg->setScaleX(590/frame2bg->getContentSize().width);
    frame2bg->setScaleY(320/frame2bg->getContentSize().height);
    frame2bg->setPosition(frame2->getPosition());
    
    CCSprite *guang2l = CCSprite::createWithSpriteFrameName("barrack_kuang_guangl.png");
    this->addChild(guang2l,6);
    guang2l->setAnchorPoint(ccp(0, 1));
    CCSprite *guang2r = CCSprite::createWithSpriteFrameName("barrack_kuang_guangl.png");
    this->addChild(guang2r,6);
    guang2r->setFlipX(true);
    guang2r->setAnchorPoint(ccp(1, 1));
    
    CCSprite *guang2m = CCSprite::createWithSpriteFrameName("barrack_kuang_guangm.png");
    this->addChild(guang2m,6);
    guang2m->setScaleX(468/guang2m->getContentSize().width);
    guang2m->setAnchorPoint(ccp(0.5, 1));
    
    guang2m->setPosition(ccpAdd(frame2->getPosition(), ccp(0, frame2->getContentSize().height*.5)));
    guang2r->setPosition(ccpAdd(guang2m->getPosition(), ccp(284+10, 0)));
    guang2l->setPosition(ccpAdd(guang2m->getPosition(), ccp(-284-10, 0)));
    
    CCScale9Sprite *fontbg = CCScale9Sprite::createWithSpriteFrameName("box_fontbg.png");
    fontbg->setPreferredSize(CCSizeMake(538, 205));
    this->addChild(fontbg,6);
    fontbg->setPosition(ccpAdd(frame2->getPosition(), ccp(0, 26)));

    
    SGConsumableDataModel *temp = SGStaticDataManager::shareStatic()->getConsumableById(_card->getItemId());
    SGCCLabelTTF* a = SGCCLabelTTF::create(temp->getConsumeDesc()->getCString(), FONT_BOXINFO, 28, CCSizeMake(504,400));
    a->setAnchorPoint(ccp(0.5f, 1));
    this->addChild(a,6);
	a->setPosition(ccpAdd(fontbg->getPosition(), ccp(0, fontbg->getContentSize().height*.33)));
	
	//setCardType,“强化合成“
	SGConsumableDataModel *consumeData = SGStaticDataManager::shareStatic()->getConsumableById(_card->getItemId());
    this->setCardType(consumeData->getConsumeType());
	
}
Beispiel #23
0
void GameSet::initContent()
{
    CCSize winSize = CCDirector::sharedDirector()->getWinSize();
    CCLayerColor *colorlayer = CCLayerColor::create(ccc4(0, 0, 0, 120));
    addChild(colorlayer);
    colorlayer->setPosition(ccp(-winSize.width/2, -winSize.height/2));
    CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("common/common.plist");
    CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("ui/gameSet/gameSet.plist");
    
    CCSprite *bg = CCSprite::create("common/commonBg_451_305.png");
    addChild(bg);
    
    CCSprite *titleBg = CCSprite::createWithSpriteFrameName("common_titleBg.png");
    bg->addChild(titleBg);
    titleBg->setPosition(ccp(bg->getContentSize().width/2 + 50, bg->getContentSize().height));
    
    CCLabelBMFont *title = CCLabelBMFont::create("设置", "font/font_uiTitle.fnt");
    titleBg->addChild(title);
    title->setPosition(ccp(titleBg->getContentSize().width/2 - 50, titleBg->getContentSize().height/2));
    
    CCScale9Sprite *frame = CCScale9Sprite::create("common/common_scale_1.png");
    frame->setPreferredSize(CCSizeMake(328, 150));
    frame->setAnchorPoint(ccp(0.5, 0.5));
    bg->addChild(frame);
    frame->setPosition(ccp(bg->getContentSize().width/2, bg->getContentSize().height/2 + 40));

    
//    CCSprite *title = CCSprite::createWithSpriteFrameName("set_title.png");
//    bg->addChild(title);
//    title->setPosition(ccp(bg->getContentSize().width/2, bg->getContentSize().height - 20));
    
    
    CCControlButton *closeBtn = INSTANCE(ButtonUtils)->createButton("common_backBtn.png", CCSizeMake(75, 81), "");
    bg->addChild(closeBtn);
    closeBtn->setPosition(ccp(bg->getContentSize().width - 20, bg->getContentSize().height - 20));
    closeBtn->addTargetWithActionForControlEvents(this, cccontrol_selector(GameSet::close), CCControlEventTouchUpInside);
    
    CCLabelBMFont *musicLabel = CCLabelBMFont::create("音乐", "font/font_common.fnt");
    bg->addChild(musicLabel);
    musicLabel->setPosition(ccp(115, 235));
    
    CCControlSlider *musicSlider = CCControlSlider::create(CCSprite::createWithSpriteFrameName("set_barFrame.png"), CCSprite::createWithSpriteFrameName("set_barFrame.png"), CCSprite::createWithSpriteFrameName("set_barBtn.png"));
    musicSlider->setAnchorPoint(ccp(0.5f, 1.0f));
    musicSlider->setMinimumValue(0.0f); // Sets the min value of range
    musicSlider->setMaximumValue(1.0f); // Sets the max value of range
    musicSlider->setTag(1);
    musicSlider->addTargetWithActionForControlEvents(this, cccontrol_selector(GameSet::musicCallBack), CCControlEventValueChanged);
    musicSlider->setPosition(ccp(260, 250));
    musicSlider->setTouchPriority(0);
    float musicVolume = CCUserDefault::sharedUserDefault()->getFloatForKey(GameSet_musicVolume, 0.5);
    musicSlider->setValue(musicVolume);
    bg->addChild(musicSlider);
    
    CCLabelBMFont *soundLabel = CCLabelBMFont::create("音效", "font/font_common.fnt");
    bg->addChild(soundLabel);
    soundLabel->setPosition(ccp(115, 185));
    
    CCControlSlider *soundSlider = CCControlSlider::create(CCSprite::createWithSpriteFrameName("set_barFrame.png"), CCSprite::createWithSpriteFrameName("set_barFrame.png"), CCSprite::createWithSpriteFrameName("set_barBtn.png"));
    soundSlider->setAnchorPoint(ccp(0.5f, 1.0f));
    soundSlider->setMinimumValue(0.0f); // Sets the min value of range
    soundSlider->setMaximumValue(1.0f); // Sets the max value of range
    soundSlider->setTag(1);
    soundSlider->addTargetWithActionForControlEvents(this, cccontrol_selector(GameSet::soundCallBack), CCControlEventValueChanged);
    soundSlider->setPosition(ccp(260, 200));
    soundSlider->setTouchPriority(0);
    float soundVolume = CCUserDefault::sharedUserDefault()->getFloatForKey(GameSet_soundVolume, 0.5);
    soundSlider->setValue(soundVolume);
    bg->addChild(soundSlider);
    
    
    CCControlButton *btn1 = INSTANCE(ButtonUtils)->createButton("set_guide.png", CCSizeMake(84, 87), "");
    
    CCControlButton *btn3 = INSTANCE(ButtonUtils)->createButton("set_contact.png", CCSizeMake(83, 84), "");
    CCControlButton *btn4 = INSTANCE(ButtonUtils)->createButton("set_develep.png", CCSizeMake(83, 92), "");
    
    bg->addChild(btn1);
    
    bg->addChild(btn3);
    bg->addChild(btn4);
    
    if(showHelp){
        wikiBtn = INSTANCE(ButtonUtils)->createButton("set_wiki.png", CCSizeMake(87, 89), "");
        bg->addChild(wikiBtn);
        btn1->setPosition(ccp(80, 50));
        wikiBtn->setPosition(ccp(180, 50));
        btn3->setPosition(ccp(280, 50));
        btn4->setPosition(ccp(380, 50));
        
        wikiBtn->addTargetWithActionForControlEvents(this, cccontrol_selector(GameSet::btn2Handler), CCControlEventTouchUpInside);
    }else{
        btn1->setPosition(ccp(80, 50));
        btn3->setPosition(ccp(230, 50));
        btn4->setPosition(ccp(380, 50));
    }
    
    btn1->addTargetWithActionForControlEvents(this, cccontrol_selector(GameSet::btn1Handler), CCControlEventTouchUpInside);
    btn3->addTargetWithActionForControlEvents(this, cccontrol_selector(GameSet::btn3Handler), CCControlEventTouchUpInside);
    btn4->addTargetWithActionForControlEvents(this, cccontrol_selector(GameSet::btn4Handler), CCControlEventTouchUpInside);
    
    
    
}