コード例 #1
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;
}
コード例 #2
0
ファイル: TextLayer.cpp プロジェクト: steinkrausls/cocotd
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;
}
コード例 #3
0
ファイル: TFBaseLayer.cpp プロジェクト: jobine/TheForce
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;
}
コード例 #4
0
ファイル: LayerChanToast.cpp プロジェクト: mrktj/iCasino_v2
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);
}
コード例 #5
0
	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();
	}
コード例 #6
0
ファイル: IrrPanel.cpp プロジェクト: mmjinggege/Irr_GDK
	bool IrrPanel::init( const char* texture,IrrSize size,bool isPlist /*= false*/ )
	{
		CCScale9Sprite* pBackground = NULL;
		if(isPlist)
		{
			CCScale9Sprite* pBackground = CCScale9Sprite::createWithSpriteFrameName(texture);
		}
		else
		{
			CCScale9Sprite* pBackground = CCScale9Sprite::create(texture);
		}
		pBackground->setAnchorPoint(ccp(0,0));
		pBackground->setContentSize(CCSize(size.width,size.height));
		this->addChild(pBackground);
		return true;
	}
コード例 #7
0
bool Scene_GameItem::init()
{
    //////////////////////////////
    // 1. super init first
    if ( !CCLayer::init() )
    {
        return false;
    }
    CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
    CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();
   
    //background
   // CCSprite* pSpriteBG = CCSprite::createWithSpriteFrameName("bg.png");
   // pSpriteBG->setPosition(ccp(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y));
//    pSpriteBG->setColor(ccGRAY);
	// by wsp
// 	CCSprite* pSpriteBG = CCSprite::createWithSpriteFrameName("GameSceneBg/GameBg.png");
// 	pSpriteBG->setAnchorPoint(ccp(0.f,0.f));
	CCScale9Sprite* pSpriteBG = CCScale9Sprite::create("./CocoStudioResources/GameSceneBg/GameBg.png");
	pSpriteBG->setAnchorPoint(ccp(0.f,0.f));
	pSpriteBG->setContentSize(CCSizeMake(visibleSize.width,visibleSize.height));
	this->addChild(pSpriteBG, 0);
	pSpriteBG->setTag(eGameItemTagBg);
	CCSprite* pSpriteBGTop = CCSprite::create();
	pSpriteBGTop->setTag(eGameItemTagBgTop);
	this->addChild(pSpriteBGTop, 0);
	
    ul = UILayer::create();
    auto myLayout = dynamic_cast<Layout*>(GUIReader::shareReader()->widgetFromJsonFile(CStringUtil::convertToUIResPath("Item.json").c_str()));
    ul->addWidget(myLayout);
    ul->setContentSize(visibleSize);
    this->addChild(ul, 1, 100);
    
    //返回按钮.
    returnBtn = dynamic_cast<UIButton*>(ul->getWidgetByName("Return"));
    returnBtn->setPressedActionEnabled(true);
    returnBtn->addReleaseEvent(this, coco_releaseselector(Scene_GameItem::returnBtnCallBack));
    
    //开始游戏按钮.
    UIButton* startGameBtn = dynamic_cast<UIButton*>(ul->getWidgetByName("StartGame"));
//    startGameBtn->setPressedActionEnabled(true);
    startGameBtn->addReleaseEvent(this, coco_releaseselector(Scene_GameItem::startGameCallBack));
    

    //道具按钮.
    UIButton* itemBtn1 = dynamic_cast<UIButton*>(ul->getWidgetByName("ItemBtn1"));
    itemBtn1->setTag(Btn_1);
    itemBtn1->addReleaseEvent(this, coco_releaseselector(Scene_GameItem::itemBtnCallBack));
    
    UIButton* itemBtn2 = dynamic_cast<UIButton*>(ul->getWidgetByName("ItemBtn2"));
    itemBtn2->setTag(Btn_2);
    itemBtn2->addReleaseEvent(this, coco_releaseselector(Scene_GameItem::itemBtnCallBack));
    UIButton* itemBtn3 = dynamic_cast<UIButton*>(ul->getWidgetByName("ItemBtn3"));
    itemBtn3->setTag(Btn_3);
    itemBtn3->addReleaseEvent(this, coco_releaseselector(Scene_GameItem::itemBtnCallBack));
    UIButton* itemBtn4 = dynamic_cast<UIButton*>(ul->getWidgetByName("ItemBtn4"));
    itemBtn4->setTag(Btn_4);
    itemBtn4->addReleaseEvent(this, coco_releaseselector(Scene_GameItem::itemBtnCallBack));
    
    

    
    //勋章任务点击.
    taskBtn = dynamic_cast<UIButton*>(ul->getWidgetByName("TitleBtn"));
    taskBtn->addReleaseEvent(this, coco_releaseselector(Scene_GameItem::taskBtnCallBack));
    taskBtn->setPressedActionEnabled(true);
   
    rankBtn = dynamic_cast<UIButton*>(ul->getWidgetByName("RankingBtn"));
    rankBtn->addReleaseEvent(this, coco_releaseselector(Scene_GameItem::rankBtnCallBack));
    rankBtn->setPressedActionEnabled(true);
    
    CTaskMan::sharedInstance().requestDayTaskSelect(GameShare_Global::shareGlobal()->gameType);
    
	//人物动画
	auto pRole = CCSprite::create("role/pig_tl/1.png");
	pRole->setTag(AniLayerTag);
	this->addChild(pRole,1);
    return true;
}
コード例 #8
0
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);
}
コード例 #9
0
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);
        }
    }

}
コード例 #10
0
ファイル: HelpLayer.cpp プロジェクト: SeedAsh/CoolStars
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;
}
コード例 #11
0
ファイル: BuyLifeLayer.cpp プロジェクト: zhulu-mike/CrazyStar
bool BuyLifeLayer::init()
{
    bool bRet = false;

    do
    {
        CC_BREAK_IF (!CCLayer::init());
		CCSprite *p = CCSprite::create(g_sPanelBGImage);
		CCSize ps = p->getContentSize();

        
		CCSize s = CCDirector::sharedDirector()->getWinSize();
		CCScale9Sprite * bg = CCScale9Sprite::create(g_sPanelBGImage,CCRectMake(0,0,ps.width,ps.height),CCRectMake(20,20,ps.width-40,ps.height-40));
		this->addChild(bg);
		bg->setAnchorPoint(ccp(0,0));
		bg->setPreferredSize(CCSizeMake(s.width,s.height-beginY));
		this->setTouchEnabled(true);
		this->setTouchPriority(-999);

		p = CCSprite::create(g_sPanelBGImage2);
		ps = p->getContentSize();
		bg = CCScale9Sprite::create(g_sPanelBGImage2,CCRectMake(0,0,ps.width,ps.height),CCRectMake(20,20,ps.width-40,ps.height-40));
		this->addChild(bg);
		bg->setAnchorPoint(ccp(0,0));
		bg->setPreferredSize(CCSizeMake(s.width-20,s.height-20-beginY));
		bg->setPositionX(10);
		bg->setPositionY(10);

		CCMenuItemImage * back = CCMenuItemImage::create(g_sBackButtonUpBGImage,g_sBackButtonDownBGImage,
														this, 
														menu_selector(BuyLifeLayer::onCommandBack));
		back->setAnchorPoint(ccp(0,1));

		MyCCMenu * backMenu = MyCCMenu::create(back,NULL);
		this->addChild(backMenu);
		backMenu->setPositionX(28);
		backMenu->setPositionY(1000-beginY);
		backMenu->setTouchPriority(-1000);

		CCSprite * t2 = CCSprite::create(g_sBigLifeBGImage);
		t2->setAnchorPoint(ccp(0,1));
		t2->setPosition(ccp(82,890-beginY));
		this->addChild(t2);

		CCSprite * price2 = CCSprite::create(g_sBuy2BGImage);
		price2->setAnchorPoint(ccp(0,1));
		price2->setPosition(ccp(157,889-beginY));
		this->addChild(price2);

		CCSprite * coin2 = CCSprite::create(g_sGoldBGImage);
		coin2->setAnchorPoint(ccp(0,1));
		coin2->setPosition(ccp(392,891-beginY));
		this->addChild(coin2);

		CCMenuItemImage * buy2 = CCMenuItemImage::create(g_sOkButtonUpBGImage,g_sOkButtonDownBGImage,
														this, 
														menu_selector(BuyLifeLayer::onCommandBuy2));
		buy2->setAnchorPoint(ccp(0,1));
		MyCCMenu * buy2Menu = MyCCMenu::create(buy2,NULL);
		this->addChild(buy2Menu);
		buy2Menu->setPositionX(534);
		buy2Menu->setPositionY(907-beginY);
		buy2Menu->setTouchPriority(-1000);

		CCSprite * t5 = CCSprite::create(g_sBigLifeBGImage);
		t5->setAnchorPoint(ccp(0,1));
		t5->setPosition(ccp(82,719-beginY));
		this->addChild(t5);

		CCSprite * price5 = CCSprite::create(g_sBuy5BGImage);
		price5->setAnchorPoint(ccp(0,1));
		price5->setPosition(ccp(157,718-beginY));
		this->addChild(price5);

		CCSprite * coin5 = CCSprite::create(g_sGoldBGImage);
		coin5->setAnchorPoint(ccp(0,1));
		coin5->setPosition(ccp(392,723-beginY));
		this->addChild(coin5);

		CCMenuItemImage * buy5 = CCMenuItemImage::create(g_sOkButtonUpBGImage,g_sOkButtonDownBGImage,
														this, 
														menu_selector(BuyLifeLayer::onCommandBuy5));
		buy5->setAnchorPoint(ccp(0,1));
		MyCCMenu * buy5Menu = MyCCMenu::create(buy5,NULL);
		this->addChild(buy5Menu);
		buy5Menu->setPositionX(534);
		buy5Menu->setPositionY(736-beginY);
		buy5Menu->setTouchPriority(-1000);

		CCSprite * t21 = CCSprite::create(g_sBigLifeBGImage);
		t21->setAnchorPoint(ccp(0,1));
		t21->setPosition(ccp(82,550-beginY));
		this->addChild(t21);

		CCSprite * price21 = CCSprite::create(g_sBuy21BGImage);
		price21->setAnchorPoint(ccp(0,1));
		price21->setPosition(ccp(152,550-beginY));
		this->addChild(price21);

		CCSprite * coin21 = CCSprite::create(g_sGoldBGImage);
		coin21->setAnchorPoint(ccp(0,1));
		coin21->setPosition(ccp(439,553-beginY));
		this->addChild(coin21);

		CCMenuItemImage * buy21 = CCMenuItemImage::create(g_sOkButtonUpBGImage,g_sOkButtonDownBGImage,
														this, 
														menu_selector(BuyLifeLayer::onCommandBuy21));
		buy21->setAnchorPoint(ccp(0,1));
		MyCCMenu * buy21Menu = MyCCMenu::create(buy21,NULL);
		this->addChild(buy21Menu);
		buy21Menu->setPositionX(534);
		buy21Menu->setPositionY(569-beginY);
		buy21Menu->setTouchPriority(-1000);

		CCSprite * t60 = CCSprite::create(g_sBigLifeBGImage);
		t60->setAnchorPoint(ccp(0,1));
		t60->setPosition(ccp(82,358-beginY));
		this->addChild(t60);

		CCSprite * price60 = CCSprite::create(g_sBuy60BGImage);
		price60->setAnchorPoint(ccp(0,1));
		price60->setPosition(ccp(163,367-beginY));
		this->addChild(price60);

		CCSprite * coin60 = CCSprite::create(g_sGoldBGImage);
		coin60->setAnchorPoint(ccp(0,1));
		coin60->setPosition(ccp(455,364-beginY));
		this->addChild(coin60);

		CCMenuItemImage * buy60 = CCMenuItemImage::create(g_sOkButtonUpBGImage,g_sOkButtonDownBGImage,
														this, 
														menu_selector(BuyLifeLayer::onCommandBuy60));
		buy60->setAnchorPoint(ccp(0,1));
		MyCCMenu * buy60Menu = MyCCMenu::create(buy60,NULL);
		this->addChild(buy60Menu);
		buy60Menu->setPositionX(534);
		buy60Menu->setPositionY(378-beginY);
		buy60Menu->setTouchPriority(-1000);

		CCSprite * t130 = CCSprite::create(g_sBigLifeBGImage);
		t130->setAnchorPoint(ccp(0,1));
		t130->setPosition(ccp(82,173-beginY));
		this->addChild(t130);

		CCSprite * price130 = CCSprite::create(g_sBuy130BGImage);
		price130->setAnchorPoint(ccp(0,1));
		price130->setPosition(ccp(162,175-beginY));
		this->addChild(price130);

		CCSprite * coin130 = CCSprite::create(g_sGoldBGImage);
		coin130->setAnchorPoint(ccp(0,1));
		coin130->setPosition(ccp(480,177-beginY));
		this->addChild(coin130);

		CCMenuItemImage * buy130 = CCMenuItemImage::create(g_sOkButtonUpBGImage,g_sOkButtonDownBGImage,
														this, 
														menu_selector(BuyLifeLayer::onCommandBuy130));
		buy130->setAnchorPoint(ccp(0,1));
		MyCCMenu * buy130Menu = MyCCMenu::create(buy130,NULL);
		this->addChild(buy130Menu);
		buy130Menu->setPositionX(534);
		buy130Menu->setPositionY(193-beginY);
		buy130Menu->setTouchPriority(-1000);


		CCDirector::sharedDirector()->getTouchDispatcher()->addTargetedDelegate(this,this->getTouchPriority(),true);
		bRet = true;

    }while(0);

    return bRet;
}
コード例 #12
0
ファイル: GameSet.cpp プロジェクト: qokelate/ThreeKingDoms
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);
    
    
    
}
コード例 #13
0
ファイル: MailListScene.cpp プロジェクト: crazyit/iGame
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;
}