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


C++ Value::getArray方法代码示例

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


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

示例1: load

void Inventory::load(JsonBox::Value& v, EntityManager* mgr)
{
	for(auto item : v.getArray())
	{
		std::string itemId = item.getArray()[0].getString();
		int quantity = item.getArray()[1].getInteger();
		this->items.push_back(std::make_pair(mgr->getEntity<T>(itemId), quantity));
	}
}
开发者ID:shanadeshana,项目名称:cpp-rpg-tutorial,代码行数:9,代码来源:inventory.cpp

示例2: unserialize

void unserialize(const JsonBox::Value & o, std::unordered_set<T> & v)
{
	const JsonBox::Array & a = o.getArray();
	for(u32 i = 0; i < a.size(); ++i)
	{
		T elem;
		unserialize(a[i], elem);
		v.insert(elem);
	}
}
开发者ID:Zylann,项目名称:SnowfeetFramework,代码行数:10,代码来源:json_utils.hpp

示例3: Check

		JsonBox::Array SpellChecker::Check(const std::string &text)
		{
			JsonBox::Value result;

			std::wstring wide_text = Helpers::String::strtowstr(text);
			std::string utf8_text = Helpers::String::ToUtf8(wide_text);

			std::string encoded_text = Helpers::String::UriEncode(utf8_text);

			std::stringstream url;
			url << m_spell_check_url << encoded_text;

			std::stringstream data;
			Helpers::Files::DownloadFile(url.str(), data);

			std::string answer = data.str();

			result.loadFromString(answer);

			return result.getArray();
		}
开发者ID:NeonMercury,项目名称:zen-diary,代码行数:21,代码来源:SpellChecker.cpp

示例4: strlen

void
MCBackpack::loadEffectiveItems()
{
    MCItemManager *itemManager = MCItemManager::sharedItemManager();
    CCUserDefault *userDefault = CCUserDefault::sharedUserDefault();
    string data = userDefault->getStringForKey(kMCEffectiveItemsKey, "");
    
    if (MCGameState::sharedGameState()->isSaveFileExists()
        && data.size() > 0) {
#if MC_DEBUG_SAVEDATA == 1
        const char *output = data.c_str();
#else
        const char *input = data.c_str();
        char *output;
        mc_size_t len = strlen(input);
        MCBase64Decode((mc_byte_t *) input, len, (mc_byte_t **) &output);
#endif
        JsonBox::Value v;
        v.loadFromString(output);
        
        JsonBox::Array effectiveItems = v.getArray();
        
        healthPotion_->count = effectiveItems.at(0).getInt();
        physicalPotion_->count = effectiveItems.at(1).getInt();
        fireballTrapWide_->count = effectiveItems.at(2).getInt();
        fireballTrapDamage_->count = effectiveItems.at(3).getInt();
        curseTrapWide_->count = effectiveItems.at(4).getInt();
        curseTrapDamage_->count = effectiveItems.at(5).getInt();
        paralysisTrapWide_->count = effectiveItems.at(6).getInt();
        paralysisTrapDamage_->count = effectiveItems.at(7).getInt();
        fogTrapWide_->count = effectiveItems.at(8).getInt();
        fogTrapDamage_->count = effectiveItems.at(9).getInt();
        flashTrapWide_->count = effectiveItems.at(10).getInt();
        flashTrapDamage_->count = effectiveItems.at(11).getInt();
#if MC_DEBUG_SAVEDATA != 1
        delete []output;
#endif
    } else {
        healthPotion_->count = 0;
        physicalPotion_->count = 0;
        fireballTrapWide_->count = 0;
        fireballTrapDamage_->count = 0;
        curseTrapWide_->count = 0;
        curseTrapDamage_->count = 0;
        paralysisTrapWide_->count = 0;
        paralysisTrapDamage_->count = 0;
        fogTrapWide_->count = 0;
        fogTrapDamage_->count = 0;
        flashTrapWide_->count = 0;
        flashTrapDamage_->count = 0;
    }
    
    /* load items */
    healthPotion_->item = itemManager->effectiveItemForObjectId(effectiveItemsOID[kMCHealthPotion]);
    healthPotion_->item->retain();
    physicalPotion_->item = itemManager->effectiveItemForObjectId(effectiveItemsOID[kMCPhysicalPotion]);
    physicalPotion_->item->retain();
    fireballTrapWide_->item = itemManager->effectiveItemForObjectId(effectiveItemsOID[kMCFireballWide]);
    fireballTrapWide_->item->retain();
    fireballTrapDamage_->item = itemManager->effectiveItemForObjectId(effectiveItemsOID[kMCFireballDamage]);
    fireballTrapDamage_->item->retain();
    curseTrapWide_->item = itemManager->effectiveItemForObjectId(effectiveItemsOID[kMCCurseWide]);
    curseTrapWide_->item->retain();
    curseTrapDamage_->item = itemManager->effectiveItemForObjectId(effectiveItemsOID[kMCCurseDamage]);
    curseTrapDamage_->item->retain();
    paralysisTrapWide_->item = itemManager->effectiveItemForObjectId(effectiveItemsOID[kMCParalysisWide]);
    paralysisTrapWide_->item->retain();
    paralysisTrapDamage_->item = itemManager->effectiveItemForObjectId(effectiveItemsOID[kMCParalysisDamage]);
    paralysisTrapDamage_->item->retain();
    fogTrapWide_->item = itemManager->effectiveItemForObjectId(effectiveItemsOID[kMCFogWide]);
    fogTrapWide_->item->retain();
    fogTrapDamage_->item = itemManager->effectiveItemForObjectId(effectiveItemsOID[kMCFogDamage]);
    fogTrapDamage_->item->retain();
    flashTrapWide_->item = itemManager->effectiveItemForObjectId(effectiveItemsOID[kMCFlashWide]);
    flashTrapWide_->item->retain();
    flashTrapDamage_->item = itemManager->effectiveItemForObjectId(effectiveItemsOID[kMCFlashDamage]);
    flashTrapDamage_->item->retain();
}
开发者ID:edison9888,项目名称:__graduation_project,代码行数:78,代码来源:MCBackpack.cpp

示例5: onMenu

void RPGBattleMenu::onMenu(cocos2d::CCObject *pObject)
{
    CCMenuItem *menuItem = (CCMenuItem*)pObject;
    SimpleAudioEngine::sharedEngine()->playEffect("audio_effect_btn.wav");

    switch (menuItem->getTag())
    {
        case kRPGBattleMenuTagSkill:
        {
            CCLog("技能");
            
            this->hideMenu();
            
            this->m_selectedMenuTag = kRPGBattleMenuTagSkill;
            
            CCMenuItemSprite *menuCancel = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("commons_btn_back_04.png"), CCSprite::createWithSpriteFrameName("commons_btn_back_04.png"), this, menu_selector(RPGBattleMenu::onMenu));
            menuCancel->setPosition(ccp(43, 596));
            menuCancel->setTag(kRPGBattleMenuTagCancel);
            menuCancel->setScale(0.75);
            this->addChild(menuCancel);
            
            CCTMXTiledMap *selectLayer = CCTMXTiledMap::create(CCString::createWithFormat("battle_select_%s.tmx", CCUserDefault::sharedUserDefault()->getStringForKey(GAME_STYLE).c_str())->getCString());
            selectLayer->setPosition(ccp((CCDirector::sharedDirector()->getWinSize().width - selectLayer->getContentSize().width) / 2, (CCDirector::sharedDirector()->getWinSize().height - selectLayer->getContentSize().height) / 2));
            selectLayer->setTag(kRPGBattleSceneLayerTagSkillSelectDialog);
            
            ((RPGBattleSceneLayer*)this->m_parentNode)->addChild(selectLayer);            
            ((RPGBattleSceneLayer*)this->m_parentNode)->enabledTouched(true);
            
            //显示title和分隔线
            addLab(selectLayer, 199, (CCString*)this->m_stringList->objectForKey("skill_title"), 25, ccp(310, 285));
            CCLabelTTF *titleLab = (CCLabelTTF*)selectLayer->getChildByTag(199);
            titleLab->setFontFillColor(ccc3(144, 144, 144));
            
            CCSprite *separate = CCSprite::createWithSpriteFrameName("separate.png");
            separate->setPosition(ccp(selectLayer->getContentSize().width / 2, 260));
            separate->setScaleX(0.65);
            separate->setTag(198);
            selectLayer->addChild(separate);
            
            //加载技能数据
            CCTableView *tableView = (CCTableView*)selectLayer->getChildByTag(197);
            if(!tableView)
            {
                tableView = CCTableView::create(this, ccp(selectLayer->getContentSize().width, selectLayer->getContentSize().height - 80));
                tableView->setDirection(kCCScrollViewDirectionVertical);
                tableView->setPosition(CCSizeZero);
                tableView->setDelegate(this);
                tableView->setVerticalFillOrder(kCCTableViewFillTopDown);
                tableView->setTag(197);
                selectLayer->addChild(tableView);
                
            }
            
            this->m_tableItems->removeAllObjects();

            string wq = "";
            JsonBox::Value json;
            json.loadFromString(this->m_playerData->m_skill.c_str());
            JsonBox::Array jsonArr = json.getArray();
            for (int i = 0; i < jsonArr.size(); i++)
            {
                char* str = (char*)malloc(10 * sizeof(char));
                OzgCCUtility::itoa(jsonArr[i].getInt(), str);
                wq.append(str);
                
                if(i + 1 < jsonArr.size())
                    wq.append(", ");
                
                free(str);
            }
            if((int)wq.length() > 0)
            {
                CppSQLite3Query query = this->m_db->execQuery(CCString::createWithFormat(SKILL_QUERY, wq.c_str())->getCString());
                while(!query.eof())
                {
                    RPGSkillBtnData *skill = RPGSkillBtnData::create();
                    skill->m_dataId = query.getIntField("id");
                    skill->m_name = query.getStringField("name_cns");
                    skill->m_MP = query.getIntField("mp");
                    skill->m_skillAttack = query.getIntField("skill_attack");
                    skill->m_type = query.getIntField("type");
                    skill->m_attr = query.getIntField("attr");
                    skill->m_enabled = true;
                    
                    //不能使用技能的情况
                    if(this->m_playerData->m_MP <= 0 || this->m_playerData->m_HP <= 0)
                        skill->m_enabled = false;
                    else if(this->m_playerData->m_MP < skill->m_MP)
                        skill->m_enabled = false;
                    
                    this->m_tableItems->addObject(skill);
                    
                    query.nextRow();
                }
                query.finalize();
            }
            
            tableView->reloadData();
            //加载技能数据 end
            
//.........这里部分代码省略.........
开发者ID:ChinaiOS,项目名称:OzgGameRPG,代码行数:101,代码来源:RPGBattleMenu.cpp


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