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


C++ CCString类代码示例

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


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

示例1: if

CCTableViewCell* HelloWorld::tableCellAtIndex(CCTableView *table, unsigned int idx)
{
    CCDictionary* pRecipe = (CCDictionary*)m_pRecipes->objectAtIndex(idx);
    CCString* pName = (CCString*)pRecipe->objectForKey("name");
    CCString* pNo   = (CCString*)pRecipe->objectForKey("recipe");
    CCString* pStep = (CCString*)pRecipe->objectForKey("step");
    
    CCString* string;
    if (pStep!=NULL) {
        string = CCString::createWithFormat("レシピ %s (ステップ%s): %s", pNo->getCString(), pStep->getCString(), pName->getCString());
    } else if (pNo->isEqual(CCString::create("0"))) {
        string = pName;
    } else {
        string = CCString::createWithFormat("レシピ %s : %s", pNo->getCString(), pName->getCString());
    }
    CCTableViewCell *cell = table->dequeueCell();
    if (!cell) {
        cell = new CCTableViewCell();
        cell->autorelease();
        
        CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
        
        int fontSize = CCEGLView::sharedOpenGLView()->getDesignResolutionSize().height/320.0f * 20;
        CCLabelTTF *label = CCLabelTTF::create(string->getCString(), "Helvetica", fontSize, CCSizeMake(visibleSize.width, visibleSize.height/5), kCCTextAlignmentCenter);
        label->setPosition(CCPointZero);
		label->setAnchorPoint(CCPointZero);
        label->setTag(123);
        cell->addChild(label);
    }
    else
    {
        CCLabelTTF *label = (CCLabelTTF*)cell->getChildByTag(123);
        label->setString(string->getCString());
    }
    
    
    return cell;
}
开发者ID:duoku,项目名称:cocos2dx_recipe,代码行数:38,代码来源:HelloWorldScene.cpp

示例2: textHandler

    void textHandler(void *ctx, const char *ch, int len)
    {
        CC_UNUSED_PARAM(ctx);
        if (m_tState == SAX_NONE)
        {
            return;
        }

        CCSAXState curState = m_tStateStack.empty() ? SAX_DICT : m_tStateStack.top();
        CCString *pText = new CCString();
        pText->m_sString = std::string((char*)ch,0,len);

        switch(m_tState)
        {
        case SAX_KEY:
            m_sCurKey = pText->m_sString;
            break;
        case SAX_INT:
        case SAX_REAL:
        case SAX_STRING:
            {
                CCAssert(!m_sCurKey.empty(), "not found key : <integet/real>");

                if (SAX_ARRAY == curState)
                {
                    m_pArray->addObject(pText);
                }
                else if (SAX_DICT == curState)
                {
                    m_pCurDict->setObject(pText, m_sCurKey);
                }
                break;
            }
        default:
            break;
        }
        pText->release();
    }
开发者ID:94smart,项目名称:SimpleGameCocos2D-x,代码行数:38,代码来源:CCFileUtils_airplay.cpp

示例3: CCString

// do not move to Player.h
void Game::setPlayerPosition(CCPoint position, CCFiniteTimeAction* sequence)
{
    CCPoint tileCoord = this->tileCoordForPosition(position);
    int tileGid = _meta->tileGIDAt(tileCoord);
    
    if (tileGid) {
        CCDictionary *properties = _tileMap->propertiesForGID(tileGid);
        if (properties) {
            // obstacle
            CCString *collision = new CCString();
            *collision = *properties->valueForKey("Collidable");
            // Moveable
            CCString *move = new CCString();
            *move = *properties->valueForKey("Moveable");
            // Breakable
            CCString *breakable = new CCString();
            *breakable = *properties->valueForKey("Breakable");
            
            if ((collision && collision->compare("True") == 0) ||
                 (move && move->compare("True") == 0) ||
                 (breakable && breakable->compare("True") == 0)) {
                // 動けない音を出す
                CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("hit.caf");
                this->finishAnimation();
                CCLog("Can't move");
                return;
            }
            
            // item get
            CCString *collectable = new CCString();
            
            *collectable = *properties->valueForKey("Collectable");
            if (collectable && (collectable->compare("True") == 0)) {
                // 取り除く
                _meta->removeTileAt(tileCoord);
                _foreground->removeTileAt(tileCoord);
                _numCollected++;
                _hud->numCollectedChanged(_numCollected);
                CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("pickup.caf");
            }
        }
    }
    
    _player->runAction(sequence);
    // not hit only 赤にする
    this->setTileEffect(position);
    CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("move.caf");
}
开发者ID:shinriyo,项目名称:expeller,代码行数:49,代码来源:GameScene.cpp

示例4: playCasterSpecific

void SkillEffectShow::playCasterSpecific(const char *path)
{
	Figure* figure = ((Monomer*)m_attacker->getParent())->getFigure();

	if (figure->getWeaponSprite() == NULL)
		return;

	Sprite* sprite = Sprite::create();
	sprite->setPosition(figure->getWeaponSprite()->getContentSize()/2);
	figure->getWeaponSprite()->addChild(sprite);

	//CCArray* array = CCArray::createWithCapacity(4);
	Vector<SpriteFrame*> array ;
	int flag = 0;

	do
	{
		CCString* string = CCString::createWithFormat("%s_%d0_%02d.png", path, figure->getDirectionType(), flag);
		SpriteFrame* spriteFrame = SpriteFrameCache::getInstance()->spriteFrameByName(string->getCString());
		CC_BREAK_IF(spriteFrame == NULL);
		array.pushBack(spriteFrame);
		flag++;
	}
	while (1);

	if (array.size() > 0)
	{
		Animation* movie = Animation::createWithSpriteFrames(array, 1 / (float)10);
		Animate* animate = Animate::create(movie);
		CallFunc* callFunc = CallFunc::create(sprite, callfunc_selector(Sprite::removeFromParent));
		Sequence* actions = Sequence::create(animate, callFunc, NULL);
		sprite->runAction(actions);
	}
	else
	{
		sprite->removeFromParent();
	}
}
开发者ID:mofr123,项目名称:game,代码行数:38,代码来源:SkillEffectShow.cpp

示例5: Rect

InputLabel::InputLabel(const char* placeHolder, const char* fontName, int fontSize, Vec2 location, ui::EditBox::InputMode inputMode, int maxChar, Size dimensions, TextHAlignment format)
{
    linkTo = NULL;
    isOpened = false;
    textDirty = false;
    originalInfos = NULL;
    isPassword = false;
    passwordText = NULL;
    name = placeHolder;
    ui::Scale9Sprite* sprite = ui::Scale9Sprite::create("green_edit.png", Rect(0, 0, 43, 38), Rect(4, 3, 35, 32));
    sprite->setPreferredSize(Size(43, 38));
    sprite->setOpacity(0);
    delegate = ui::EditBox::create(dimensions, sprite);
    delegate->retain();
    if(strlen(placeHolder) > 0)
    {
        CCString* placeholderWithBrackets = ScreateF("<%s>", placeHolder);
        delegate->setPlaceHolder(placeholderWithBrackets->getCString());
        this->setInitialText(placeholderWithBrackets);
    }
    delegate->setFontColor(Color3B::BLACK);
    delegate->setDelegate(this);
    
    this->setPosition(location);
    delegate->setInputMode(inputMode);
    numbersOnly = inputMode ==  ui::EditBox::InputMode::DECIMAL;
    delegate->setReturnType(ui::EditBox::KeyboardReturnType::DONE);
    delegate->setInputFlag(ui::EditBox::InputFlag::INITIAL_CAPS_SENTENCE);
    if(maxChar != -1)
    {
        delegate->setMaxLength(maxChar);
    }
    listeners.pushBack(Director::getInstance()->getEventDispatcher()->addCustomEventListener("OpenKeyboard", std::bind(&InputLabel::openKeyboard, this, std::placeholders::_1)));
    listeners.pushBack(Director::getInstance()->getEventDispatcher()->addCustomEventListener("CloseKeyboard", std::bind(&InputLabel::closeKeyboard, this, std::placeholders::_1)));
    listeners.pushBack(Director::getInstance()->getEventDispatcher()->addCustomEventListener("DisableInputs", std::bind(&InputLabel::disableInputs, this, std::placeholders::_1)));
    listeners.pushBack(Director::getInstance()->getEventDispatcher()->addCustomEventListener("EnableInputs", std::bind(&InputLabel::enableInputs, this, std::placeholders::_1)));
    
}
开发者ID:poplax,项目名称:FenneXEmptyProject,代码行数:38,代码来源:InputLabel.cpp

示例6: CCTableViewCell

CCTableViewCell* S3TestMain::tableCellAtIndex(CCTableView *table, unsigned int idx)
{
//    CCString *strCell = CCString::createWithFormat("Practice %d",idx);
    CCString *strCell = CCString::create(aVectorCellValue[idx].c_str());
    CCTableViewCell *pCell = table->dequeueCell();
    if (!pCell) {
        pCell = new CCTableViewCell();
        pCell->autorelease();
        CCSprite *pSprite = CCSprite::create();//("cellLine.png");
        pSprite->setAnchorPoint(CCPointZero);
		pSprite->setPosition(CCPointZero);
        pCell->addChild(pSprite);
        
        {
            CCLabelTTF *pLabel = CCLabelTTF::create(strCell->getCString(), "Arial", s3FontSize3_macro, s3Size2_macro(aCell), kCCTextAlignmentLeft, kCCVerticalTextAlignmentCenter);
            pLabel->setPosition(ccp(s3Less2_macro,0));
            pLabel->setAnchorPoint(CCPointZero);
            pLabel->setColor(ccc3(0,0,0));
            pLabel->setTag(10);
            pCell->addChild(pLabel,1);
        }
        
        {
            CCLabelTTF *pLabel = CCLabelTTF::create("Locked", "Arial",s3FontSize3_macro, s3Size3_macro(aItem), kCCTextAlignmentRight, kCCVerticalTextAlignmentCenter);
            pLabel->setPosition(s3Position8_macro(aItem));
            pLabel->setAnchorPoint(CCPointZero);
            pLabel->setColor(ccc3(0,0,255));
            pLabel->setTag(10);
            pCell->addChild(pLabel,1);
        }
        
    }
    
    CCLabelTTF *pLabel = (CCLabelTTF*)pCell->getChildByTag(10);
    pLabel->setString(strCell->getCString());
    
    return pCell;
}
开发者ID:liuyuyefz,项目名称:GreTest,代码行数:38,代码来源:S3TestScene.cpp

示例7: getTargetCallback

CCAction * SFCallFuncO::ccAction(void)
{
	CCObject * pTargetCallback = getTargetCallback();
	CCString * pSelector = getSelector();
	if (!pTargetCallback || !pSelector)
	{
		CNLog("error");
		return NULL;
	}
	CNSelectorDelegate * pCallback = dynamic_cast<CNSelectorDelegate *>(pTargetCallback);
	if (!pCallback)
	{
		CNLog("cannot get selector: %s", pSelector->getCString());
		return NULL;
	}
	SEL_CallFuncO selector = pCallback->getSelectorO(pSelector->getCString());
	if (!selector)
	{
		CNLog("no such selector: %s", pSelector->getCString());
		return NULL;
	}
	return CCCallFuncO::actionWithTarget(pTargetCallback, selector, m_pObject);
}
开发者ID:moky,项目名称:SpriteForest,代码行数:23,代码来源:SFActionInstant.cpp

示例8: createPriceWithDictionary

Price createPriceWithDictionary(CCDictionary * dict)
{
	Price::CoinType coinType;
	uint32 value;
	
	CCString * strType = (CCString *)dict->objectForKey(PRICE_TYPE_KEY);
	if (strType->compare(PRICE_COIN) == 0)
	{
		coinType = Price::kCoinType_Coin;
	}
	else if (strType->compare(PRICE_GEM) == 0)
	{
		coinType = Price::kCoinType_Gem;
	}
	else
	{
		coinType = Price::kCoinType_Unknown;
	}
	
	CCString * strNumber = (CCString *)dict->objectForKey(PRICE_VALUE_KEY);
	value = strNumber->uintValue();
	return Price(coinType, value);
}
开发者ID:QiuleiWang,项目名称:cocos2d-x-2.x-utils,代码行数:23,代码来源:CommonUtils.cpp

示例9:

void Recipe15::eat(float delta)
{
	CCSprite* player = (CCSprite*) this->getChildByTag(1);
	player->setTexture(CCTextureCache::sharedTextureCache()->addImage("monkey01.png"));

	CCSize winSize = CCDirector::sharedDirector()->getWinSize();

	this->m_points += player->getPositionX()/(winSize.width/4) + 1;

	CCLabelTTF* label = (CCLabelTTF*)this->getChildByTag(11);

	CCString* points = CCString::createWithFormat("%d", this->m_points);

	label->setString(points->getCString());

	CCAnimationCache* cache = CCAnimationCache::sharedAnimationCache();
	cache->addAnimationsWithFile("animations.plist");

	CCAnimation* animation2 = cache->animationByName("bite");

	CCAnimate* action = CCAnimate::create(animation2);
	player->runAction(action);
}
开发者ID:n1ck0g0m3z,项目名称:GameRecipe,代码行数:23,代码来源:Recipe15.cpp

示例10: createSoulIcon

void AnimationManager::createSoulIcon(int soul, CCPoint point){
    CCString *string = CCString::createWithFormat("+%i", soul);
    CCLabelTTF *soulGainLabel = CCLabelTTF::create(string->getCString(), Main_Font, 128);
    soulGainLabel->setColor(ccMAGENTA);

    LabelWrapper *labelWrapper = new LabelWrapper();
    labelWrapper->initWithLabel(soulGainLabel);
    labelWrapper->setPosition(point);
    GM->gameLayer->addChild(labelWrapper, 1000000);
    //    CCScaleTo *action = CCScaleTo::create(.05, .4);
    //    CCEaseIn *ease = CCEaseIn::create(action, 1.0);
    CCDelayTime *delay = CCDelayTime::create(.8);
    CCFadeOut *fade = CCFadeOut::create(.4);
    CCCallFunc *obj = CCCallFunc::create(labelWrapper, callfunc_selector(BaseObject::removeBaseObject));
    
    CCSequence *seq = CCSequence::create( delay, fade, obj, NULL);
    labelWrapper->runAction(seq);
    /*    AnimationObject *animationObject = new AnimationObject();
     animationObject->init(seq, icon);
     animationObject->duration = .04;*/
    
    //this->addAnimation(animationObject);
}
开发者ID:francis1122,项目名称:RogueDeck,代码行数:23,代码来源:AnimationManager.cpp

示例11: Notification

void RankUp::Notification(CCObject* obj)
{
    CCString* param = (CCString*)obj;

    if (param->intValue() == 5)
    {
        // 자랑하기 블록
        ((CCSprite*)spriteClass->FindSpriteByName("button/btn_red_mini.png1"))->setColor(ccc3(150,150,150));
        ((CCSprite*)spriteClass->FindSpriteByName("letter/letter_boast.png"))->setColor(ccc3(150,150,150));
        isBoasted = true;
    }

    else if (param->intValue() == 10)
    {
        // 터치 풀기 (백그라운드에서 돌아올 때)
        isTouched = false;
        if (idx > -1)
        {
            spriteClass->spriteObj[idx]->sprite->setColor(ccc3(255,255,255));
            ((CCSprite*)spriteClass->FindSpriteByName("letter/letter_confirm_mini.png"))->setColor(ccc3(255,255,255));
        }
    }
}
开发者ID:playdandi,项目名称:CocoDrawingMagic,代码行数:23,代码来源:RankUp.cpp

示例12:

CCAnimation * CCNodeLoader::parsePropTypeAnimation(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) {
    CCString * animationFile = pCCBReader->readCachedString();
    CCString * animation = pCCBReader->readCachedString();
    
    CCAnimation * ccAnimation = NULL;
    
    // Support for stripping relative file paths, since ios doesn't currently
    // know what to do with them, since its pulling from bundle.
    // Eventually this should be handled by a client side asset manager
    // interface which figured out what resources to load.
    // TODO Does this problem exist in C++?
    animation = CCBReader::lastPathComponent(animation);
    animationFile = CCBReader::lastPathComponent(animationFile);
    
    if (animation != NULL && animation->compare("") != 0) 
    {
        CCAnimationCache * animationCache = CCAnimationCache::sharedAnimationCache();
        animationCache->addAnimationsWithFile(animationFile->getCString());
        
        ccAnimation = animationCache->animationByName(animation->getCString());
    }
    return ccAnimation;
}
开发者ID:1901,项目名称:CCDate,代码行数:23,代码来源:CCNodeLoader.cpp

示例13: fetchNext

int CCPreLoad::fetchNext()
{
	if(!m_dict)
		return -1;

	if(m_tmpIdx >= (int)m_dict->count() - 1)
		return 0; 

	if(!m_tmpKeyArr && initFetch()!=0)
	{
		return -1;
	}

	++m_tmpIdx;

	CCString* p = dynamic_cast<CCString*>(m_tmpKeyArr->objectAtIndex(m_tmpIdx));
	if(!p)
		return -1;	
	
	m_tmpFileName = p->getCString();

	return 1;
}
开发者ID:marszaya,项目名称:huihe,代码行数:23,代码来源:CPreLoad.cpp

示例14: propertyNamed

	void CCTMXLayer::parseInternalProperties()
	{
		// if cc_vertex=automatic, then tiles will be rendered using vertexz

		CCString *vertexz = propertyNamed("cc_vertexz");
		if( vertexz ) 
		{
			if( vertexz->m_sString == "automatic" )
			{
				m_bUseAutomaticVertexZ = true;
			}
			else
			{
				m_nVertexZvalue = vertexz->toInt();
			}
		}

		CCString *alphaFuncVal = propertyNamed("cc_alpha_func");
		if (alphaFuncVal)
		{
			m_fAlphaFuncValue = alphaFuncVal->toFloat();
		}
	}
开发者ID:alexzzp,项目名称:cocos2dx-wince,代码行数:23,代码来源:CCTMXLayer.cpp

示例15: Kecheng

bool KechengController::updateKecheng(bool isWin){
    Kecheng* kecheng=new Kecheng();
    kecheng->setIntid(0);
    kecheng->setIntwin(0);
    kecheng->setIntlose(0);
    S_DM->getByKey(kecheng, m_kcid);
    
    if (isWin) {
        kecheng->setIntwin(kecheng->getwin()+1);
    }else{
        kecheng->setIntlose(kecheng->getlose()+1);
    }
    
    CCString* sql;
    int now=(int)(TimeUtils::millisecondNow().tv_sec);
    if (kecheng->getid()==0) {
        sql=CCString::createWithFormat("insert into kecheng(id,win,lose,lastTime) values(%d,%d,%d,%d)",m_kcid,kecheng->getwin(),kecheng->getlose(),now);
    }else{
        sql=CCString::createWithFormat("update kecheng set win=%d,lose=%d,lastTime=%d where id=%d",m_kcid,kecheng->getwin(),kecheng->getlose(),now);
    }
    CC_SAFE_DELETE(kecheng);
    return S_DM->executeSql(sql->getCString());
}
开发者ID:echenonline,项目名称:Blackcat,代码行数:23,代码来源:KechengController.cpp


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