本文整理汇总了C++中CCString::toInt方法的典型用法代码示例。如果您正苦于以下问题:C++ CCString::toInt方法的具体用法?C++ CCString::toInt怎么用?C++ CCString::toInt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCString
的用法示例。
在下文中一共展示了CCString::toInt方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UpdatePlayerGrade
void Player::UpdatePlayerGrade(CCObject *pSender)
{
CCString* str = static_cast<CCString*>(pSender);
_grade += str->toInt();
CCNotificationCenter::sharedNotifCenter()->postNotification(NOTIFY_PLAYER_UPDATEUIGRADE);
UpdateData();
CCLog("playerGrade ===== %d", _grade);
PostFreshMonsterVec();
}
示例2: UpdateMonsterKind
void MonsterKindVector::UpdateMonsterKind(CCObject *pSender)
{
int nowGrade = PlayerMrg::getInstance()->getPlayer()->getPlayerGrade();
if (pSender)
{
CCString* str = static_cast<CCString*>(pSender);
nowGrade = str->toInt();
}
bool bIsAdded = false;
for (size_t i = 0; i < Monster_KindNumber; ++i)
{
bool bExist = false;
for (std::vector<int>::iterator it = _monsterKindId.begin(); it != _monsterKindId.end(); it++)
{
if (*it == _monsterId[i])
{
bExist = true;
break;
}
}
if (!bExist)
{
int showGrade = MonsterData::getInstance()->getShowGrade(_monsterId[i]);
if (nowGrade < showGrade)
{
//break;
continue;
}
else
{
_monsterKindId.push_back(_monsterId[i]);
bIsAdded = true;
}
}
/*if (std::find(_monsterKindId.begin(), _monsterKindId.end(), _monsterId[i]) == _monsterKindId.end())
{
int showGrade = MonsterData::getInstance()->getShowGrade(_monsterId[i]);
if (nowGrade < showGrade)
{
break;
}
else
{
_monsterKindId.push_back(_monsterId[i]);
bIsAdded = true;
}
}
continue;*/
}
if(bIsAdded)
CCNotificationCenter::sharedNotifCenter()->postNotification(NOTIFY_MONSTER_UPDATEFRESHPOOL);
}
示例3: getAttributePositive
bool NiStream::getAttributePositive(mutableDic* dic, std::string key)
{
if (dic == NULL)
return false;
CCString* keyValue = static_cast<CCString*>(dic->objectForKey(key.c_str()));
if (keyValue == NULL)
return false;
return keyValue->toInt() != 0;
}
示例4: getSignedIntAttributeValue
bool NiStream::getSignedIntAttributeValue(mutableDic* dic,
std::string key,
int32_t& value)
{
if (dic == NULL)
return false;
CCString* keyValue = static_cast<CCString*>(dic->objectForKey(key.c_str()));
if (keyValue == NULL)
return false;
value = keyValue->toInt();
return true;
}
示例5: UpdatePlayerNowHp
void Player::UpdatePlayerNowHp(CCObject *pSender)
{
CCString* str = static_cast<CCString*>(pSender);
int tempHp = _nowHp;
tempHp += str->toInt();
if (tempHp >= _HpLimit)
{
_nowHp = _HpLimit;
}
else if (tempHp < _HpLimit && tempHp > 0)
{
_nowHp = tempHp;
}
else
{
//½áËã½çÃæ
_nowHp = 0;
CCNotificationCenter::sharedNotifCenter()->postNotification(NOTIFY_GETRESLUT);
}
CCNotificationCenter::sharedNotifCenter()->postNotification(NOTIFY_PLAYER_UPDATEUINOWHP);
}
示例6: parseInternalProperties
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();
}
}
示例7: CCAssert
void GB2ShapeCache::addShapesWithFile(const std::string &plist) {
const char *fullName = CCFileUtils::fullPathFromRelativePath(plist.c_str());
ObjectDict *dict = CCFileUtils::dictionaryWithContentsOfFile(fullName);
CCAssert(dict != NULL, "Shape-file not found"); // not triggered - cocos2dx delivers empty dict if non was found
CCAssert(dict->count() != 0, "plist file empty or not existing");
ObjectDict *metadataDict = (ObjectDict *)dict->objectForKey("metadata");
int format = static_cast<CCString *>(metadataDict->objectForKey("format"))->toInt();
ptmRatio = static_cast<CCString *>(metadataDict->objectForKey("ptm_ratio"))->toFloat();
CCAssert(format == 1, "Format not supported");
ObjectDict *bodyDict = (ObjectDict *)dict->objectForKey("bodies");
b2Vec2 vertices[b2_maxPolygonVertices];
ObjectDict::CCObjectMapIter iter;
bodyDict->begin();
std::string bodyName;
ObjectDict *bodyData;
while ((bodyData = (ObjectDict *)bodyDict->next(&bodyName))) {
BodyDef *bodyDef = new BodyDef();
bodyDef->anchorPoint = CCPointFromString(static_cast<CCString *>(bodyData->objectForKey("anchorpoint"))->toStdString().c_str());
CCMutableArray<ObjectDict *> *fixtureList = (CCMutableArray<ObjectDict *> *)(bodyData->objectForKey("fixtures"));
FixtureDef **nextFixtureDef = &(bodyDef->fixtures);
CCMutableArray<ObjectDict *>::CCMutableArrayIterator iter;
for (iter = fixtureList->begin(); iter != fixtureList->end(); ++iter) {
b2FixtureDef basicData;
ObjectDict *fixtureData = *iter;
basicData.filter.categoryBits = static_cast<CCString *>(fixtureData->objectForKey("filter_categoryBits"))->toInt();
basicData.filter.maskBits = static_cast<CCString *>(fixtureData->objectForKey("filter_maskBits"))->toInt();
basicData.filter.groupIndex = static_cast<CCString *>(fixtureData->objectForKey("filter_groupIndex"))->toInt();
basicData.friction = static_cast<CCString *>(fixtureData->objectForKey("friction"))->toFloat();
basicData.density = static_cast<CCString *>(fixtureData->objectForKey("density"))->toFloat();
basicData.restitution = static_cast<CCString *>(fixtureData->objectForKey("restitution"))->toFloat();
basicData.isSensor = (bool)static_cast<CCString *>(fixtureData->objectForKey("isSensor"))->toInt();
CCString *cb = static_cast<CCString *>(fixtureData->objectForKey("userdataCbValue"));
int callbackData = 0;
if (cb)
callbackData = cb->toInt();
std::string fixtureType = static_cast<CCString *>(fixtureData->objectForKey("fixture_type"))->toStdString();
if (fixtureType == "POLYGON") {
CCMutableArray<ObjectDict *> *polygonsArray = (CCMutableArray<ObjectDict *> *)(fixtureData->objectForKey("polygons"));
CCMutableArray<ObjectDict *>::CCMutableArrayIterator iter;
for (iter = polygonsArray->begin(); iter != polygonsArray->end(); ++iter) {
FixtureDef *fix = new FixtureDef();
fix->fixture = basicData; // copy basic data
fix->callbackData = callbackData;
b2PolygonShape *polyshape = new b2PolygonShape();
int vindex = 0;
CCMutableArray<CCString *> *polygonArray = (CCMutableArray<CCString *> *)(*iter);
assert(polygonArray->count() <= b2_maxPolygonVertices);
CCMutableArray<CCString *>::CCMutableArrayIterator piter;
for (piter = polygonArray->begin(); piter != polygonArray->end(); ++piter) {
CCPoint offset = CCPointFromString((*piter)->toStdString().c_str());
vertices[vindex].x = (offset.x / ptmRatio) ;
vertices[vindex].y = (offset.y / ptmRatio) ;
vindex++;
}
polyshape->Set(vertices, vindex);
fix->fixture.shape = polyshape;
// create a list
*nextFixtureDef = fix;
nextFixtureDef = &(fix->next);
}
} else if (fixtureType == "CIRCLE") {
FixtureDef *fix = new FixtureDef();
fix->fixture = basicData; // copy basic data
fix->callbackData = callbackData;
ObjectDict *circleData = (ObjectDict *)fixtureData->objectForKey("circle");
b2CircleShape *circleShape = new b2CircleShape();
circleShape->m_radius = static_cast<CCString *>(circleData->objectForKey("radius"))->toFloat() / ptmRatio;
CCPoint p = CCPointFromString(static_cast<CCString *>(circleData->objectForKey("position"))->toStdString().c_str());
circleShape->m_p = b2Vec2(p.x / ptmRatio, p.y / ptmRatio);
fix->fixture.shape = circleShape;
// create a list
*nextFixtureDef = fix;
nextFixtureDef = &(fix->next);
//.........这里部分代码省略.........