本文整理汇总了C++中CCString::retain方法的典型用法代码示例。如果您正苦于以下问题:C++ CCString::retain方法的具体用法?C++ CCString::retain怎么用?C++ CCString::retain使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCString
的用法示例。
在下文中一共展示了CCString::retain方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateOnce
void SecondLayer::updateOnce(float x)
{
CCString* sData = CCString::create("HelloWorldScene's data");
sData->retain();
CCNotificationCenter::sharedNotificationCenter()->postNotification("test", sData);
}
示例2: readStringCacheEntry
void CCBReader::readStringCacheEntry() {
int b0 = this->readByte();
int b1 = this->readByte();
int numBytes = b0 << 8 | b1;
const unsigned char * src = (const unsigned char *) (this->mBytes + this->mCurrentByte);
CCString * string = CCString::createWithData(src, (unsigned long)numBytes);
string->retain();
this->mCurrentByte += numBytes;
this->mStringCache.push_back(string);
}
示例3: downloadFile
void ParseFile::downloadFile(const char* url, const char* savePathName)
{
CCString* strSavePathName = CCString::create(savePathName);
strSavePathName->retain();
ParseManager::instance()->request(CCHttpRequest::kHttpGet,
url,
0,
0,
this,
(SEL_CallFuncND)&ParseFile::downloadFileFinished,
0,
false,
(void*)strSavePathName);
}
示例4: MCObjectIdToDickKey
void
MCItemManager::loadEffectiveItems()
{
JsonBox::Value v;
JsonBox::Object root;
JsonBox::Object::iterator rootIterator;
MCEffectiveItem *item;
MCEffectManager *effectManager = MCEffectManager::sharedEffectManager();
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
CCString* pstrFileContent = CCString::createWithContentsOfFile(kMCEffectiveItemFilepath);
if (pstrFileContent) {
v.loadFromString(pstrFileContent->getCString());
}
#else
v.loadFromFile(CCFileUtils::sharedFileUtils()->fullPathForFilename(kMCEffectiveItemFilepath).c_str());
#endif
root = v.getObject();
for (rootIterator = root.begin(); rootIterator != root.end(); ++rootIterator) {
const char *c_str_o_id = rootIterator->first.c_str();
JsonBox::Object object = rootIterator->second.getObject();
mc_object_id_t o_id = {
c_str_o_id[0],
c_str_o_id[1],
c_str_o_id[2],
c_str_o_id[3]
};
if (o_id.class_ == 'P') {
item = MCEffectiveItem::create();
} else {
MCTrap *trap = new MCTrap;
trap->init(o_id);
trap->autorelease();
item = trap;
}
CCString *ccstring;
item->setID(o_id);
ccstring = CCString::create(object["name"].getString().c_str());
item->setName(ccstring);
ccstring->retain();
ccstring = CCString::create(object["description"].getString().c_str());
item->setDescription(ccstring);
ccstring->retain();
ccstring = CCString::create(object["icon"].getString().c_str());
item->setIcon(ccstring);
ccstring->retain();
/* effect-id */
c_str_o_id = object["effect-id"].getString().c_str();
mc_object_id_t e_id = {
c_str_o_id[0],
c_str_o_id[1],
c_str_o_id[2],
c_str_o_id[3]
};
MCEffect *effect = effectManager->effectForObjectId(e_id);
item->effect = effect;
effect->retain();
item->setPrice(object["price"].getInt());
item->radius = object["radius"].getInt() * 24 / CC_CONTENT_SCALE_FACTOR(); /* 24为一个单位 */
item->hp = object["hp"].getInt();
item->pp = object["pp"].getInt();
item->positive_state = object["positive-state"].getInt();
item->lasting_time = object["lasting-time"].isDouble()
? (float) object["lasting-time"].getDouble()
: (float) object["lasting-time"].getInt();
effectiveItems_->setObject(item, MCObjectIdToDickKey(o_id));
}
}
示例5: MCMakeDiceType
void
MCItemManager::loadEquipmentItems()
{
JsonBox::Value weapon;
JsonBox::Value armor;
JsonBox::Object root;
JsonBox::Object::iterator rootIterator;
MCOreManager *oreManager = MCOreManager::sharedOreManager();
/* 读取武器 */
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
CCString* pstrFileContent = CCString::createWithContentsOfFile(kMCEquipmentItemWeaponFilepath);
if (pstrFileContent) {
weapon.loadFromString(pstrFileContent->getCString());
}
#else
weapon.loadFromFile(CCFileUtils::sharedFileUtils()->fullPathForFilename(kMCEquipmentItemWeaponFilepath).c_str());
#endif
root = weapon.getObject();
for (rootIterator = root.begin(); rootIterator != root.end(); ++rootIterator) {
const char *c_str_o_id = rootIterator->first.c_str();
JsonBox::Object object = rootIterator->second.getObject();
mc_object_id_t o_id = {
c_str_o_id[0],
c_str_o_id[1],
c_str_o_id[2],
c_str_o_id[3]
};
MCEquipmentItem *item = MCEquipmentItem::create(MCEquipment::MCWeapon);
CCString *ccstring;
item->setID(o_id);
ccstring = CCString::create(object["name"].getString().c_str());
item->setName(ccstring);
ccstring->retain();
ccstring = CCString::create(object["icon"].getString().c_str());
item->setIcon(ccstring);
ccstring->retain();
item->setPrice(object["price"].getInt());
JsonBox::Object damage = object["damage"].getObject();
MCWeapon *equipment = dynamic_cast<MCWeapon *>(item->equipment_);
/* effect-id */
c_str_o_id = object["effect-id"].getString().c_str();
mc_object_id_t e_id = {
c_str_o_id[0],
c_str_o_id[1],
c_str_o_id[2],
c_str_o_id[3]
};
MCEffectManager *effectManager = MCEffectManager::sharedEffectManager();
MCEffect *effect = effectManager->effectForObjectId(e_id);
equipment->attackEffect = effect;
effect->retain();
equipment->damage = MCMakeDiceType(damage["count"].getInt(), damage["size"].getInt());
equipment->criticalHit = object["critical-hit"].getInt();
JsonBox::Object diceRange = object["critical-hit-visible"].getObject();
JsonBox::Object diceRangeDice = diceRange["dice"].getObject();
equipment->criticalHitVisible.min = diceRange["min"].getInt();
equipment->criticalHitVisible.max = diceRange["max"].getInt();
equipment->criticalHitVisible.dice = MCMakeDiceType(diceRangeDice["count"].getInt(),
diceRangeDice["size"].getInt());
diceRange = object["critical-hit-invisible"].getObject();
diceRangeDice = diceRange["dice"].getObject();
equipment->criticalHitInvisible.min = diceRange["min"].getInt();
equipment->criticalHitInvisible.max = diceRange["max"].getInt();
equipment->criticalHitInvisible.dice = MCMakeDiceType(diceRangeDice["count"].getInt(),
diceRangeDice["size"].getInt());
equipment->distance = object["distance"].getInt();
if (object["effect"].isInteger()) {
equipment->effect = object["effect"].getInt();
diceRange = object["effect-check"].getObject();
diceRangeDice = diceRange["dice"].getObject();
equipment->effectCheck.min = diceRange["min"].getInt();
equipment->effectCheck.max = diceRange["max"].getInt();
equipment->effectCheck.dice = MCMakeDiceType(diceRangeDice["count"].getInt(),
diceRangeDice["size"].getInt());
} else {
equipment->effect = MCNormalState;
}
/* consume Double */
equipment->consume = object["consume"].isDouble()
? (float) object["consume"].getDouble()
: (float) object["consume"].getInt();
equipment->dexterity = object["dexterity"].getInt();
/* action-effect String */
equipment->actionEffect.assign(object["action-effect"].getString());
/* 读取默认矿石,加载背包的时候更新为正确矿石 */
item->ore_ = oreManager->defaultOre();
equipmentItems_->setObject(item, MCObjectIdToDickKey(o_id));
}
/* 读取防具 */
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
//.........这里部分代码省略.........
示例6: if
void
MCMercenaryManager::loadMercenaries()
{
JsonBox::Value v;
JsonBox::Object mercenaries;
JsonBox::Object::iterator mercenariesIterator;
MCDiceMaker *diceMaker = MCDiceMaker::sharedDiceMaker();
CCString *ccstring;
MCEffectManager *effectManager = MCEffectManager::sharedEffectManager();
MCSkillManager *skillManager = MCSkillManager::sharedSkillManager();
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
CCString* pstrFileContent = CCString::createWithContentsOfFile(kMCMercenariesFilepath);
if (pstrFileContent) {
v.loadFromString(pstrFileContent->getCString());
}
#else
v.loadFromFile(CCFileUtils::sharedFileUtils()->fullPathForFilename(kMCMercenariesFilepath).c_str());
#endif
mercenaries = v.getObject();
for (mercenariesIterator = mercenaries.begin();
mercenariesIterator != mercenaries.end();
++mercenariesIterator) {
const char *c_str_o_id = mercenariesIterator->first.c_str();
mc_object_id_t m_id = {
c_str_o_id[0],
c_str_o_id[1],
c_str_o_id[2],
c_str_o_id[3]
};
JsonBox::Object mercenaryObject = mercenariesIterator->second.getObject();
MCMercenary *mercenary;
if (m_id.sub_class_ == '9') {
mercenary = new MCMercenary;
} else if (m_id.sub_class_ == '8') {
mercenary = new MCNervousMercenary;
} else {
CCAssert(false, "数据错误!");
continue;
}
mercenary->init();
mercenary->autorelease();
mercenary->setID(m_id);
/* name String */
ccstring = CCString::create(mercenaryObject["name"].getString().c_str());
mercenary->setName(ccstring);
ccstring->retain();
/* face String */
ccstring = CCString::create(mercenaryObject["face"].getString().c_str());
mercenary->setFace(ccstring);
ccstring->retain();
/* build sprite sheet file path */
ccstring = CCString::createWithFormat("%s/%c-%s",
kMCSpriteSheetBaseDirectory,
c_str_o_id[0] | 32,
c_str_o_id + 1);
mercenary->setSpriteSheet(ccstring);
ccstring->retain();
/* effect-id */
c_str_o_id = mercenaryObject["effect-id"].getString().c_str();
mc_object_id_t e_id = {
c_str_o_id[0],
c_str_o_id[1],
c_str_o_id[2],
c_str_o_id[3]
};
MCEffect *effect = effectManager->effectForObjectId(e_id);
mercenary->setAttackEffect(effect);
effect->retain();
/* cost Integer */
mercenary->cost_ = mercenaryObject["cost"].getInt();
/* HP Integer */
mercenary->setHP(mercenaryObject["HP"].getInt());
mercenary->setMaxHP(mercenary->getHP());
/* dying Integer 胆怯佣兵独有 */
if (mercenary->mercenaryType_ == MCMercenary::MCNervousMercenary) {
dynamic_cast<MCNervousMercenary *>(mercenary)->setDying(mercenaryObject["dying"].getInt());
}
/* PP Integer */
mercenary->setPP(mercenaryObject["PP"].getInt());
mercenary->setMaxPP(mercenary->getPP());
/* consume Double */
mercenary->setConsume(mercenaryObject["consume"].isDouble()
? (float) mercenaryObject["consume"].getDouble()
: (float) mercenaryObject["consume"].getInt());
/* exhaustion Integer */
mercenary->setExhaustion(mercenaryObject["exhaustion"].getInt());
/* tired Integer */
mercenary->setTired(mercenaryObject["tired"].getInt());
/* dexterity Integer */
mercenary->setDexterity(mercenaryObject["dexterity"].getInt());
/* AC Integer */
mercenary->setAC(mercenaryObject["AC"].getInt());
/* armor-check-penalty Integer */
mercenary->setArmorCheckPenalty(mercenaryObject["armor-check-penalty"].getInt());
/* damage Object */
//.........这里部分代码省略.........
示例7: ccp
bool
MCRoleBaseInfo::init(MCRole *aRole)
{
if (CCLayer::init()) {
CCPoint anchorPoint = ccp(0, 1);
CCPoint labelAnchorPoint = ccp(0, 0.05);
CCSize labelSize;
CCPoint labelPosition;
CCLabelTTF *separatorLabel;
float y;
float contentScaleFactor = CC_CONTENT_SCALE_FACTOR();
CCSize faceBoxSize = CCSizeMake(72 / contentScaleFactor,
72 / contentScaleFactor);
CCRect faceBoxSourceRect = CCRectMake(0, 0, 34, 34);
CCRect faceBoxInseRect = CCRectMake(4, 4, 30, 30);
faceBox_ = CCScale9Sprite::create(kMCRoleBaseInfoFaceBoxFilepath,
faceBoxSourceRect,
faceBoxInseRect);
addChild(faceBox_);
faceBox_->setContentSize(faceBoxSize);
faceBox_->setAnchorPoint(anchorPoint);
faceBox_->setPosition(ccp(0, 0));
face_ = CCSprite::create(aRole->getFace()->getCString());
addChild(face_);
face_->setAnchorPoint(anchorPoint);
face_->setScale(64 / contentScaleFactor / face_->getContentSize().height);
face_->setPosition(ccp(4 / contentScaleFactor, -4 / contentScaleFactor));
faceBoxSelected_ = CCScale9Sprite::create(kMCRoleBaseInfoFaceBoxSelectedFilepath,
faceBoxSourceRect,
faceBoxInseRect);
addChild(faceBoxSelected_);
faceBoxSelected_->setContentSize(faceBoxSize);
faceBoxSelected_->setAnchorPoint(anchorPoint);
faceBoxSelected_->setPosition(ccp(0, 0));
faceBoxSelected_->setVisible(false);
CCSprite *valueBox = CCSprite::create(kMCRoleBaseInfoValueBoxFilepath);
addChild(valueBox);
valueBox->setOpacity(196);
valueBox->setAnchorPoint(anchorPoint);
valueBox->setPosition(ccp(faceBox_->getPositionX() + faceBoxSize.width, 0));
/* PP */
CCString *ccstring = CCString::createWithFormat("%-03.0f", aRole->getPP());
ppLabel_ = CCLabelTTF::create(ccstring->getCString(), "Marker Felt", kMCFontSize);
addChild(ppLabel_);
labelSize = ppLabel_->getContentSize();
ppLabel_->setColor(ccc3(240, 240, 240));
ppLabel_->setAnchorPoint(labelAnchorPoint);
y = labelSize.height / 2 - faceBoxSelected_->getContentSize().height;
ppLabel_->setPosition(ccp(96 / contentScaleFactor, y));
ccstring->retain();
separatorLabel = CCLabelTTF::create(" / ", "Marker Felt", kMCFontSize);
addChild(separatorLabel);
separatorLabel->setColor(ccc3(240, 240, 240));
separatorLabel->setAnchorPoint(labelAnchorPoint);
separatorLabel->setPosition(ccp(96 / contentScaleFactor + labelSize.width, y));
labelPosition = separatorLabel->getPosition();
ccstring = CCString::createWithFormat("%03.0f", aRole->getMaxPP());
maxPPLabel_ = CCLabelTTF::create(ccstring->getCString(), "Marker Felt", kMCFontSize);
addChild(maxPPLabel_);
maxPPLabel_->setColor(ccc3(240, 240, 240));
maxPPLabel_->setAnchorPoint(labelAnchorPoint);
maxPPLabel_->setPosition(ccp(labelPosition.x + separatorLabel->getContentSize().width, y));
ccstring->retain();
/* HP */
ccstring = CCString::createWithFormat("%-03hu", aRole->getHP());
hpLabel_ = CCLabelTTF::create(ccstring->getCString(), "Marker Felt", kMCFontSize);
addChild(hpLabel_);
labelSize = hpLabel_->getContentSize();
hpLabel_->setColor(ccc3(51, 153, 51));
hpLabel_->setAnchorPoint(labelAnchorPoint);
y += labelSize.height;
hpLabel_->setPosition(ccp(96 / contentScaleFactor, y));
ccstring->retain();
separatorLabel = CCLabelTTF::create(" / ", "Marker Felt", kMCFontSize);
addChild(separatorLabel);
separatorLabel->setColor(ccc3(51, 153, 51));
separatorLabel->setAnchorPoint(labelAnchorPoint);
separatorLabel->setPosition(ccp(96 / contentScaleFactor + labelSize.width, y));
labelPosition = separatorLabel->getPosition();
ccstring = CCString::createWithFormat("%03hu", aRole->getMaxHP());
maxHPLabel_ = CCLabelTTF::create(ccstring->getCString(), "Marker Felt", kMCFontSize);
addChild(maxHPLabel_);
maxHPLabel_->setColor(ccc3(51, 153, 51));
maxHPLabel_->setAnchorPoint(labelAnchorPoint);
maxHPLabel_->setPosition(ccp(labelPosition.x + separatorLabel->getContentSize().width, y));
ccstring->retain();
role_ = aRole;
aRole->retain();
//.........这里部分代码省略.........