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


C++ CCString::toStdString方法代码示例

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


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

示例1: setPlayerPosition

void HelloWorld::setPlayerPosition(cocos2d::CCPoint position)
{
	CCPoint tileCoord = this->tileCoordForPosition(position);
	int tileGid = _meta->tileGIDAt(tileCoord);
	if (tileGid)
	{
		CCDictionary<std::string, CCString*> *properties = _tileMap->propertiesForGID(tileGid);
		if (properties)
		{
			CCString *collision = properties->objectForKey("Collidable");
			if (collision && (collision->toStdString().compare("True") == 0))
			{
				SimpleAudioEngine::sharedEngine()->playEffect("hit.caf");
				return;
			}
			
			CCString *collectable = properties->objectForKey("Collectable");
			if (collectable && (collectable->toStdString().compare("True") == 0))
			{
				_meta->removeTileAt(tileCoord);
				_foreground->removeTileAt(tileCoord);
				
				_numCollected++;
				_hud->numCollectedChanged(_numCollected);
				SimpleAudioEngine::sharedEngine()->playEffect("pickup.caf");
				
				if (_numCollected == 2) {
					this->win();
				}
			}
		}
	}
	SimpleAudioEngine::sharedEngine()->playEffect("move.caf");
	_player->setPosition(position);
}
开发者ID:Ratel13,项目名称:TileBasedGamePart3Cocos2D-x,代码行数:35,代码来源:HelloWorldScene.cpp

示例2: checkCollisionForPosition

bool PtMap::checkCollisionForPosition(CCPoint position)
{
	bool collidable = false;
	position = tileCoordForPosition(position);
	int tileGID = _metaLayer->tileGIDAt(position);
	// Collision checking
	// In previous Versions, this method checked for every eventuality (Water, NPCs, etc) and that was very expensive.
	// Right now, it only checks for the Collidable property. Every NPC that steps on a tile makes it collidable and passable again after it
	// leaves. Water is collidable, but reacts on Action and has its own water property.
	if (tileGID)
	{
		CCStringToStringDictionary *properties = _tileMap->propertiesForGID(tileGID);
		if (properties)
		{
			CCString *collision = properties->objectForKey("Collidable");
			if (collision && strcmp(collision->toStdString().c_str(),"True") == 0) 
			{
				// If Collidable is true, return Yes
				collidable = true;
			}
			else 
			{
				// If not, ... well.
				collidable = false;
			}	
		}		
	}
	
	return collidable;
}
开发者ID:peteo,项目名称:RPG_Learn,代码行数:30,代码来源:PtMap.cpp

示例3: requestProductsCompleted

void CCStoreScene::requestProductsCompleted(CCArray* products, CCArray* invalidProductsId)
{
    CCNative::cancelAlert();
    CCNative::createAlert("LOAD PRODUCTS COMPLETED", "Load products completed. Check console output", "OK");
    CCNative::showAlert();
    
    printf("\n");
    for (int i = 0; i < products->count(); ++i)
    {
        CCStoreProduct* product = static_cast<CCStoreProduct*>(products->objectAtIndex(i));
        printf("PRODUCT ID: %s\n",              product->getProductIdentifier().c_str());
        printf("  localizedTitle: %s\n",        product->getLocalizedTitle().c_str());
        printf("  localizedDescription: %s\n",  product->getLocalizedDescription().c_str());
        printf("  priceLocale: %s\n",           product->getPriceLocale().c_str());
        printf("  price: %0.2f\n",              product->getPrice());
    }
    printf("\n");
    
    if (invalidProductsId->count() > 0)
    {
        printf("FOUND INVALID PRODUCTS ID\n");
        for (int i = 0; i < invalidProductsId->count(); ++i)
        {
            CCString* ccid = static_cast<CCString*>(invalidProductsId->objectAtIndex(i));
            printf("  %s\n", ccid->toStdString().c_str());
        }
    }
    
    printf("\n");
}
开发者ID:AungPyae,项目名称:cocos2d-x-extensions,代码行数:30,代码来源:CCStoreScene.cpp

示例4:

const char * CCButton::titleForState(CCControlState mState)
{
    CCString * mTepNodeInList = (CCString *) (this->titleCCStrings->objectForKey((int)mState));
    if (mTepNodeInList != NULL) {
        return mTepNodeInList->toStdString().c_str();
    }
    return NULL;
}
开发者ID:1901,项目名称:cocos2d-x-extensions,代码行数:8,代码来源:CCButton.cpp

示例5: setTitleBMFontForState

void CCControlButton::setTitleBMFontForState(const char * fntFile, CCControlState state)
{
    CCString * title = this->getTitleForState(state);
    if (!title)
    {
        title = new CCString();
    }
    this->setTitleLabelForState(CCLabelBMFont::labelWithString(title->toStdString().c_str(), fntFile), state);
}
开发者ID:tungt84,项目名称:cocos2d-blackberry,代码行数:9,代码来源:CCControlButton.cpp

示例6: getStringattributeValue

 bool NiStream::getStringattributeValue(mutableDic* dic,
                                             std::string key, 
                                             std::string& value)
 {
     if (dic == NULL)
         return false;
     
     CCString* keyValue = static_cast<CCString*>(dic->objectForKey(key.c_str()));
     if (keyValue == NULL)
         return false;
     
     value = keyValue->toStdString();
     
     return true;
 }
开发者ID:niuzb,项目名称:hellopetclient,代码行数:15,代码来源:NiStream.cpp

示例7: setTitleForState

void CCButton::setTitleForState(const char * mTitle,CCControlState mState)
{
    if (mTitle == NULL) {
        return;
    }

    CCLabelTTF * mTepNode = (CCLabelTTF *) (this->getChildByTag(CCButtonTitleTag));
    if (mTepNode != NULL) {
        mTepNode->setString(mTitle);
    }
    else {
        CCSize mContentSize = this->getContentSize();
        mTepNode = CCLabelTTF::labelWithString(mTitle, "Arial", 14);
        mTepNode->setTag(CCButtonTitleTag);
        this->setPosition(ccp(mContentSize.width/2.0,mContentSize.height/2.0));
        this->addChild(mTepNode, CCButtonZorder2);
    }

    CCSize mContentSize = mTepNode->getContentSize();
    mContentSize.width += 8;
    mContentSize.height += 6;
    this->setContentSize(mContentSize);

    CCString * mTepNodeInList = (CCString *) (this->titleCCStrings->objectForKey((int)mState));
    if (mTepNodeInList != NULL) {
        std::string mTepString = mTepNodeInList->toStdString();
        std::string mTepCompareString(mTitle);
        if (mTepString.compare(mTepCompareString) == 0) {
            return;
        }
        this->titleCCStrings->removeObjectForKey((int)mState);
    }

    //save string
    CCString * mNormalCCString = new CCString(mTitle);
    mNormalCCString->autorelease();
    this->titleCCStrings->setObject(mNormalCCString,mState);
}
开发者ID:1901,项目名称:cocos2d-x-extensions,代码行数:38,代码来源:CCButton.cpp

示例8:

PtMap::PtMap(std::string mapName)
:_tileMap(NULL)
,_bgLayer(NULL)
,_gameObjects(NULL)
,_fgLayer(NULL)
,_extraLayer(NULL)
,_metaLayer(NULL)
,_npcs(NULL)
,_doors(NULL)
,_loadedMap(NULL)
,_mapSize_x(0)
,_mapSize_y(0)
{
	char pTempMap[32] = {0};
	sprintf(pTempMap,"%s.tmx",mapName.c_str());
	CCLOG("tiledMapWithTMXFile[%s]",pTempMap);
	
	_tileMap = CCTMXTiledMap::tiledMapWithTMXFile(pTempMap);
	
	//[NSString stringWithFormat:@"%@.tmx",mapName]];
	
	// Load layers and make the meta Layer invisible
	_bgLayer    = _tileMap->layerNamed("bg");
	_fgLayer    = _tileMap->layerNamed("fg");
	_extraLayer = _tileMap->layerNamed("extras");
	_metaLayer  = _tileMap->layerNamed("meta");
	_metaLayer->setIsVisible(true);
	_gameObjects = _tileMap->objectGroupNamed("go");
	
	// Cycle through all Gameobjects and check their type, sort them into arrays accordingly
	_npcs  = CCArray::arrayWithCapacity(10);
	_doors = CCArray::arrayWithCapacity(10);
	
	for (int i = 0; i < _gameObjects->getObjects()->count(); i += 1) 
	{
		if (_gameObjects->getObjects()->getObjectAtIndex(i))
		{
			CCString *objectType = _gameObjects->getObjects()->getObjectAtIndex(i)->objectForKey("type");
			
			if (objectType && strcmp(objectType->toStdString().c_str(),"NPC") == 0) 
			{
				_npcs->addObject(_gameObjects->getObjects()->getObjectAtIndex(i));
			}
			else
			{
				if (objectType && strcmp(objectType->toStdString().c_str(),"door") == 0) 
				{
					_doors->addObject(_gameObjects->getObjects()->getObjectAtIndex(i));
					CCLOG("Door count is %i",_doors->count());
				}
			}
		}
	}
	
	// Set mapsize properties (actual size)
	_mapSize_x = _tileMap->getTileSize().width  * _tileMap->getMapSize().width;
	_mapSize_y = _tileMap->getTileSize().height * _tileMap->getMapSize().height;
	
	// Mapname property
	CC_SAFE_DELETE(_loadedMap);
	_loadedMap = new std::string(mapName);
}
开发者ID:peteo,项目名称:RPG_Learn,代码行数:62,代码来源:PtMap.cpp


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