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


C++ CCScale9Sprite类代码示例

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


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

示例1:

void CCAnimate9SpriteProgress::startWithTarget(CCNode* target)
{
    CCActionInterval::startWithTarget(target);
    
    CCScale9Sprite* sprite = (CCScale9Sprite*)target;
    beginSize = sprite->getContentSize();
}
开发者ID:13609594236,项目名称:ph-open,代码行数:7,代码来源:CCCallLambda.cpp

示例2:

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

示例3: size

CCMenuItemSprite * CCMenuItemDynamic::dynamicItemWithText(const char* text,  const char* font, const CCSize &minSize,  const char*normalImage, const char *selectedImage, CCObject* target, SEL_MenuHandler selector, const CCRect& centerRegion, GLubyte opacity) {
	  //Create the label
	  CCLabelBMFont *label = CCLabelBMFont ::labelWithString(text ,font);
	  label ->setOpacity(opacity);

	  //Calculate the Dynamic Button size
	  float minWidth = label->getContentSize().width>minSize.width?label->getContentSize().width:minSize.width;
	  float minHeight = label->getContentSize().height>minSize.height?label->getContentSize().height:minSize.height;

	  CCSize size(minWidth+30,minHeight+24);

	  label->setPosition(ccp(size.width*0.5f, size.height*0.5f));

	  //Sprite normal
	  CCScale9Sprite *normalSprite = CCScale9Sprite::scale9SpriteWithFile(normalImage, centerRegion);	
	  normalSprite ->setContentSize(size);
	  normalSprite ->setOpacity(opacity);
	  //Sprite selected
	  CCScale9Sprite *selectedSprite = NULL;
	  if(selectedImage){
		  selectedSprite = CCScale9Sprite::scale9SpriteWithFile(selectedImage, centerRegion);	
		  selectedSprite ->setContentSize(size);
		  selectedSprite->setOpacity(opacity);
	  }

	  //Create the CCMenuItemSprite
	  CCMenuItemSprite* returnItem = CCMenuItemSprite::itemFromNormalSprite(normalSprite,selectedSprite,target, selector);
	  returnItem->addChild(label);
	  return returnItem;

}
开发者ID:jandujar,项目名称:zatacka-clone-cocos2d-x,代码行数:31,代码来源:CCMenuItemDynamic.cpp

示例4: ccp

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:

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

示例6: setOpacity

void CAIndicator::setOpacity(GLubyte opacity)
{
    CCScale9Sprite* indicator = dynamic_cast<CCScale9Sprite*>(m_pIndicator);
    if (indicator)
    {
        indicator->setOpacity(opacity);
        indicator->setColor(ccc3(opacity, opacity, opacity));
    }
}
开发者ID:chuzig,项目名称:CrossApp,代码行数:9,代码来源:CAScrollView.cpp

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

示例8: CCScale9Sprite

CCScale9Sprite* CCScale9Sprite::createWithSpriteFrame(CCSpriteFrame* spriteFrame, CCRect capInsets)
{
    CCScale9Sprite* pReturn = new CCScale9Sprite();
    if ( pReturn && pReturn->initWithSpriteFrame(spriteFrame, capInsets) )
    {
        CC_SAFE_AUTORELEASE(pReturn);
        return pReturn;
    }
    CC_SAFE_DELETE(pReturn);
    return NULL;
}
开发者ID:imuzi,项目名称:cocos2dx-classical,代码行数:11,代码来源:CCScale9Sprite.cpp

示例9: CCScale9Sprite

CCScale9Sprite* CCScale9Sprite::createWithImage(CAImage* texture)
{
	CCScale9Sprite* pReturn = new CCScale9Sprite();
	if (pReturn && pReturn->initWithImage(texture))
	{
		pReturn->autorelease();
		return pReturn;
	}
	CC_SAFE_DELETE(pReturn);
	return NULL;
}
开发者ID:jonesgithub,项目名称:CrossApp,代码行数:11,代码来源:CCScale9Sprite.cpp

示例10: CCScale9Sprite

CCScale9Sprite* CCScale9Sprite::createWithSpriteFrame(CCSpriteFrame* spriteFrame)
{
    CCScale9Sprite* pReturn = new CCScale9Sprite();
    if ( pReturn && pReturn->initWithSpriteFrame(spriteFrame) )
    {
        pReturn->autorelease();
        return pReturn;
    }
    CC_SAFE_DELETE(pReturn);
    return NULL;
}
开发者ID:0309,项目名称:cocos2d-x,代码行数:11,代码来源:CCScale9Sprite.cpp

示例11: switch

void BBProgressBar::updateProgress()
{

    float pv = (m_fCurrent - m_fMin) / (m_fMax - m_fMin);
    if(m_fMax - m_fMin == 0) pv=0;
    if(pv<0) pv=0;
    if(pv>1) pv=1;

    switch (m_nProgressBarMode)
    {
    case BB_PROGRESSBAR_MODE_SCALE:
    {
    }
    break;


    //基于9格缩放的进度条机制
    case BB_PROGRESSBAR_MODE_LAYOUT:
    {
        CCSize sizeLayout = m_pBackground->getContentSize();
        sizeLayout.width *= pv;

        CCScale9Sprite* pro = dynamic_cast<CCScale9Sprite*>(m_pProgress);
        if(pro)
        {
            pro->setPreferredSize(sizeLayout);

            if(m_bHideProgress) pro->setVisible(false);
            else if(pv>0.01) pro->setVisible(true);
            else pro->setVisible(false);
        }

        if(m_pLabel)
        {
            m_pLabel->setString(FORMAT("%d", (int)m_fCurrent));
        }
    }
    break;

    case BB_PROGRESSBAR_MODE_CIRCLE:
    {
        if(m_pPotentiometer)
        {
            m_pPotentiometer->setMaximumValue(m_fMax);
            m_pPotentiometer->setMinimumValue(m_fMin);
            m_pPotentiometer->setValue(m_fCurrent);
        }
    }
    break;
    }
};
开发者ID:newcl,项目名称:boom,代码行数:51,代码来源:BBProgressBar.cpp

示例12: menu_selector

void PopCancelLayer::onEnter(){
	PopLayer::onEnter();
	CCMenuItemImage* cancelBtn = CCMenuItemImage::create("strangedesign/Dlg_cancel_button.png",
		"strangedesign/Dlg_cancel_button_down.png",
		this,
		menu_selector(PopCancelLayer::cancelCallback));
	CCScale9Sprite* background = getSprite9BackGround();
	CCPoint centerDlg = background->getPosition();
	CCSize backgroundSize = background->getContentSize();
	CCPoint rightCorner = centerDlg+ccp(backgroundSize.width/2, backgroundSize.height/2);
	CCSize cancelImgSize = cancelBtn->getContentSize();
	cancelBtn->setPosition(rightCorner-ccp(cancelImgSize.width/2,cancelImgSize.height/2));
	getMenuButton()->addChild(cancelBtn);
}
开发者ID:echenonline,项目名称:writing,代码行数:14,代码来源:PopCancelLayer.cpp

示例13: setScrollBar

	void setScrollBar(CCScale9Sprite *s){
		if(_scrollBar){ _scrollBar->removeAllChildrenWithCleanup(true);}
		_scrollBar = s;
		if(s){
			addChild(s, 255);
		}
	}
开发者ID:13609594236,项目名称:quick-cocos2d-x,代码行数:7,代码来源:LuaTableView.hpp

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

示例15: setScrollTrack

	void setScrollTrack(CCScale9Sprite *st){
		if(_scrollTrack){ _scrollTrack->removeAllChildrenWithCleanup(true);}
		_scrollTrack = st;
		if(st){
			addChild(st, 254);
		}
	}
开发者ID:13609594236,项目名称:quick-cocos2d-x,代码行数:7,代码来源:LuaTableView.hpp


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