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


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

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


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

示例1: 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

示例2: 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

示例3:

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

示例4: 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

示例5: initTabs

void GameRankLayer::initTabs()
{
	// Friend Tab
	CCScale9Sprite* ptrTabFriendsSelected = GameUtils::createScale9("new_blue_bg.png",
		CCRectMake(0,0,200,82),CCRectMake(35,35,125,10));
	ptrTabFriendsSelected->setContentSize(CCSizeMake(204,82));
	CCScale9Sprite* ptrTabFriendsDisabled = GameUtils::createScale9("new_blue_bg.png",
		CCRectMake(0,0,200,82),CCRectMake(35,35,125,10));
	ptrTabFriendsDisabled->setContentSize(CCSizeMake(204,82));
	CCNode* ptrTabFriendsNormal = CCNode::create();
	ptrTabFriendsNormal->setContentSize(ptrTabFriendsSelected->getContentSize());

	m_ptrTabFriends = CCMenuItemSprite::create(ptrTabFriendsNormal, ptrTabFriendsSelected, 
		ptrTabFriendsDisabled, this, menu_selector(GameRankLayer::tabFriendsCallback));
	m_ptrBg->addChild(m_ptrTabFriends);
	LayoutUtil::layoutParentLeftTop(m_ptrTabFriends, -5, -27);
	registerMenuItem(m_ptrTabFriends);

	m_ptrLbFriends = CCLabelBMFont::create(LOCALIZED_STRING("word_friends"), 
		FontConstant::BMFONT_GOTHIC725_BLK_BT_BLUE);
	m_ptrLbFriends->setScale(0.6f);
	m_ptrTabFriends->addChild(m_ptrLbFriends);
	LayoutUtil::layoutParentBottom(m_ptrLbFriends,6,22);

	// Global Tab
	CCScale9Sprite* ptrTabGlobalSelected = GameUtils::createScale9("new_blue_bg.png",
		CCRectMake(0,0,200,82),CCRectMake(35,35,125,10));
	ptrTabGlobalSelected->setContentSize(CCSizeMake(204,82));
	CCScale9Sprite* ptrTabGlobalDisabled = GameUtils::createScale9("new_blue_bg.png",
		CCRectMake(0,0,200,82),CCRectMake(35,35,125,10));
	ptrTabGlobalDisabled->setContentSize(CCSizeMake(204,82));
	CCNode* ptrTabGlobalNormal = CCNode::create();
	ptrTabGlobalNormal->setContentSize(ptrTabGlobalSelected->getContentSize());
	m_ptrTabGolbal = CCMenuItemSprite::create(ptrTabGlobalNormal, ptrTabGlobalSelected,
		ptrTabGlobalDisabled,this, menu_selector(GameRankLayer::tabGlobalCallback));
	m_ptrBg->addChild(m_ptrTabGolbal);
	LayoutUtil::layoutRight(m_ptrTabGolbal,m_ptrTabFriends,-44);
	registerMenuItem(m_ptrTabGolbal);

	m_ptrLbGlobal = CCLabelBMFont::create(LOCALIZED_STRING("word_global"), 
		FontConstant::BMFONT_GOTHIC725_BLK_BT_BLUE);
	m_ptrLbGlobal->setScale(0.6f);
	m_ptrTabGolbal->addChild(m_ptrLbGlobal);
	LayoutUtil::layoutParentBottom(m_ptrLbGlobal,5,22);

	tabFriendsCallback(NULL);
}
开发者ID:forappengine,项目名称:texasholdem,代码行数:47,代码来源:GameRankLayer.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: 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

示例8: 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

示例9: init

	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;
	}
开发者ID:mmjinggege,项目名称:Irr_GDK,代码行数:16,代码来源:IrrPanel.cpp

示例10: 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

示例11: 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

示例12: getTarget

void CCAnimate9SpriteProgress::update(float fraction)
{
    CCNode* target = getTarget();
    CCScale9Sprite* sprite = (CCScale9Sprite*)target;
    
    float width = beginSize.width + fraction * distance;

    if (capAtMax)
        width = std::min(width, maxWidth);
    else
        while (width - maxWidth > 1e-3) width -= maxWidth;
    
    if (width - minWidth < 1e-3)
        width = minWidth;
    
    sprite->setVisible(width > minWidth);
    sprite->setContentSize(CCSize(width, beginSize.height));
}
开发者ID:13609594236,项目名称:ph-open,代码行数:18,代码来源:CCCallLambda.cpp

示例13: 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

示例14: 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

示例15: CCLog

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);
        }
    }
//.........这里部分代码省略.........
开发者ID:KuaiFaMaster,项目名称:KuaifaCppDemo,代码行数:101,代码来源:ArenaWindow.cpp


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