当前位置: 首页>>代码示例>>C++>>正文


C++ CCScale9Sprite::setPosition方法代码示例

本文整理汇总了C++中CCScale9Sprite::setPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ CCScale9Sprite::setPosition方法的具体用法?C++ CCScale9Sprite::setPosition怎么用?C++ CCScale9Sprite::setPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CCScale9Sprite的用法示例。


在下文中一共展示了CCScale9Sprite::setPosition方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: updateScroll

	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());
	}
开发者ID:13609594236,项目名称:quick-cocos2d-x,代码行数:35,代码来源:LuaTableView.hpp

示例2: init

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;
}
开发者ID:doanhtdpl,项目名称:dau-truong-tri-thuc,代码行数:49,代码来源:MoreDiamondDialog.cpp

示例3: DerSelMenu

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;
}
开发者ID:steinkrausls,项目名称:cocotd,代码行数:60,代码来源:TextLayer.cpp

示例4:

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
		));
}
开发者ID:longguai,项目名称:game-DarkWar,代码行数:25,代码来源:LFToast.cpp

示例5: onEnter

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++;
	}
开发者ID:mrktj,项目名称:iCasino_v2,代码行数:30,代码来源:PopupLayer.cpp

示例6: initQuestionItems

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]);
	}
}
开发者ID:doanhtdpl,项目名称:dau-truong-tri-thuc,代码行数:47,代码来源:SoloGameScene.cpp

示例7:

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;
}
开发者ID:jobine,项目名称:TheForce,代码行数:9,代码来源:TFBaseLayer.cpp

示例8: CCSize

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);
}
开发者ID:mrktj,项目名称:iCasino_v2,代码行数:56,代码来源:LayerChanToast.cpp

示例9: resetScroll

	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();
	}
开发者ID:13609594236,项目名称:quick-cocos2d-x,代码行数:43,代码来源:LuaTableView.hpp

示例10: showImmediately

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());
}
开发者ID:SongCF,项目名称:game-LostStar,代码行数:55,代码来源:AchievementNotification.cpp

示例11: init

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;
}
开发者ID:wenhulove333,项目名称:ScutServer,代码行数:48,代码来源:CCControlPotentiometerTest.cpp

示例12: init

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;
}
开发者ID:csdnnet,项目名称:hiygame,代码行数:47,代码来源:CCControlScene.cpp

示例13: init

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;
    }
开发者ID:524777134,项目名称:cocos2d-x,代码行数:45,代码来源:CCControlButtonTest.cpp

示例14: init

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;
}
开发者ID:0309,项目名称:cocos2d-x,代码行数:44,代码来源:CCControlScene.cpp

示例15: onEnter

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);
    
}
开发者ID:peterdocter,项目名称:Coco2dxDemo,代码行数:37,代码来源:ModelDialog.cpp


注:本文中的CCScale9Sprite::setPosition方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。