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


C++ CCArray::getObjectAtIndex方法代码示例

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


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

示例1: init

bool BaseBlock::init(BlockType type, cocos2d::Vec2 position)
{
    cocos2d::Size collisionSize;
    cocos2d::Vec2 speed;
    float score;
    float stamina;
    float time;
    std::string filename;
    
    bool result;

    cocos2d::Size visibleSize = Director::getInstance()->getVisibleSize();
    cocos2d::Vec2 origin = Director::getInstance()->getVisibleOrigin();
    
    std::string blockid = CommonUtil::itos((int)type + BLOCKIDBASE);
    
    //碰撞盒信息
    std::string collision = CommonUtil::getPropById(blockid, "collision");
    CCArray * colli = CommonUtil::split(collision.c_str(), ",");
    collisionSize.width = (dynamic_cast<CCString*>(colli->getObjectAtIndex(0)))->floatValue();
    collisionSize.height = (dynamic_cast<CCString*>(colli->getObjectAtIndex(1)))->floatValue();
    //速度信息
    std::string speedstr = CommonUtil::getPropById(blockid, "speed");
    speedstr.erase(0,1);
    speedstr.erase(speedstr.end()-1, speedstr.end());
    CCArray * speedli = CommonUtil::split(speedstr.c_str(), ",");
    speed.x = (dynamic_cast<CCString*>(speedli->getObjectAtIndex(0)))->floatValue();
    speed.y = (dynamic_cast<CCString*>(speedli->getObjectAtIndex(1)))->floatValue();
    //躲过得分数
    score = atof(CommonUtil::getPropById(blockid, "score").c_str());
    //碰撞消耗的体力值
    stamina = atof(CommonUtil::getPropById(blockid, "stamina").c_str());
    //碰撞效果影响时间
    time = atof(CommonUtil::getPropById(blockid, "time").c_str());
    //图片文件名
    filename = CommonUtil::getPropById(blockid, "filename");
    //effectlist
    std::string efflist = CommonUtil::getPropById(blockid, "effectlist");
    CCArray * efflistarr = CommonUtil::split(efflist.c_str(), ",");
    
    Ref * obj;
   
    CCARRAY_FOREACH(efflistarr, obj)
    {
        int temp = dynamic_cast<CCString*>(obj)->intValue();
        mBlockEffectList.push_back(temp);
    }
开发者ID:ourgames,项目名称:MiniGames,代码行数:47,代码来源:Block.cpp

示例2: init

bool Item::init(ItemType type, cocos2d::Vec2 position)
{
    cocos2d::Size magnetSize;
    cocos2d::Vec2 speed;
  
    float value;
    float time;
    std::string filename;
    
    bool result;
    
    cocos2d::Size visibleSize = Director::getInstance()->getVisibleSize();
    cocos2d::Vec2 origin = Director::getInstance()->getVisibleOrigin();
    
    std::string itemid = CommonUtil::itos((int)type + ITEMIDBASE);
    
    // magnet
    std::string magstr = CommonUtil::getPropById(itemid, "magnetsize");
    CCArray * magli = CommonUtil::split(magstr.c_str(), ",");
    magnetSize.width = (dynamic_cast<CCString*>(magli->getObjectAtIndex(0)))->floatValue();
    magnetSize.height = (dynamic_cast<CCString*>(magli->getObjectAtIndex(1)))->floatValue();
    //速度信息
    std::string speedstr = CommonUtil::getPropById(itemid, "speed");
    speedstr.erase(0,1);
    speedstr.erase(speedstr.end()-1, speedstr.end());
    CCArray * speedli = CommonUtil::split(speedstr.c_str(), ",");
    speed.x = (dynamic_cast<CCString*>(speedli->getObjectAtIndex(0)))->floatValue();
    speed.y = (dynamic_cast<CCString*>(speedli->getObjectAtIndex(1)))->floatValue();
   
    //
    value = atof(CommonUtil::getPropById(itemid, "value").c_str());
    //碰撞效果影响时间
    time = atof(CommonUtil::getPropById(itemid, "time").c_str());
    //图片文件名
    filename = CommonUtil::getPropById(itemid, "filename");
    //effectlist
    std::string efflist = CommonUtil::getPropById(itemid, "effectlist");
    CCArray * efflistarr = CommonUtil::split(efflist.c_str(), ",");
    
    Ref * obj;
    
    CCARRAY_FOREACH(efflistarr, obj)
    {
        int temp = dynamic_cast<CCString*>(obj)->intValue();
        mItemEffectList.push_back(temp);
    }
开发者ID:ourgames,项目名称:MiniGames,代码行数:46,代码来源:Item.cpp

示例3: LoadText

void CAttackConfig::LoadText()
{
	std::string  data = cocos2d::FileUtils::getInstance()->getStringFromFile(StressText);
	String* ns = CCString::createWithFormat("%s", data.c_str());
	CCArray* array = CCGlobleConfig::split(ns->getCString(), "\n");
	for (int i = 1; i < array->count(); i++)
	{
		String * str = static_cast<String*>(array->getObjectAtIndex(i));
		CCArray * strarray = CCGlobleConfig::split(str->getCString(), "\t");
		CAttackData *data = new CAttackData();
		int index = 0;
		String * str0 = static_cast<String*>(strarray->getObjectAtIndex(index++));
		data->ID = str0->intValue();
		str0->release();
		String * str1 = static_cast<String*>(strarray->getObjectAtIndex(index++));
		data->Name = str1->getCString();
		str1->release();
		String * str2 = static_cast<String*>(strarray->getObjectAtIndex(index++));
		data->TargetRank = str2->intValue();
		str2->release();
		String * str3 = static_cast<String*>(strarray->getObjectAtIndex(index++));
		data->TargetType = str3->intValue();
		str3->release();
		String * str7 = static_cast<String*>(strarray->getObjectAtIndex(index++));
		data->AttackPoint = str7->intValue();
		str7->release();

		String * str4 = static_cast<String*>(strarray->getObjectAtIndex(index++));
		data->BulletType = str4->intValue();
		str4->release();
		String * str5 = static_cast<String*>(strarray->getObjectAtIndex(index++));
		CCArray* carr = CCGlobleConfig::split(str5->getCString(), ",");
		for (int n = 0; n < carr->count(); n++)
		{
			data->BulletValue[n] = static_cast<String*>(carr->getObjectAtIndex(n))->floatValue();
		}
		str5->release();

		String * str9 = static_cast<String*>(strarray->getObjectAtIndex(index++));
		data->EffectId = str9->intValue();
		str9->release();
		String* str10 = static_cast<String*>(strarray->getObjectAtIndex(index++));
		data->EffectValue = str10->intValue();
		str10->release();

		str10 = static_cast<String*>(strarray->getObjectAtIndex(index++));
		data->ResourceName1 = str10->getCString();
		str10->release();
		str10 = static_cast<String*>(strarray->getObjectAtIndex(index++));
		data->ResourceFrameCount1 = str10->intValue();
		str10->release();
		str10 = static_cast<String*>(strarray->getObjectAtIndex(index++));
		data->ResourceName2 = str10->getCString();
		str10->release();
		str10 = static_cast<String*>(strarray->getObjectAtIndex(index++));
		data->ResourceFrameCount2 = str10->intValue();
		str10->release();
		str10 = static_cast<String*>(strarray->getObjectAtIndex(index++));
		data->ResourceName3 = str10->getCString();
		str10->release();
		str10 = static_cast<String*>(strarray->getObjectAtIndex(index++));
		data->ResourceFrameCount3 = str10->intValue();
		str10->release();

		str10 = static_cast<String*>(strarray->getObjectAtIndex(index++));
		data->AttackVoice = str10->getCString();
		str10->release();
		str10 = static_cast<String*>(strarray->getObjectAtIndex(index++));
		data->HitVoice = str10->getCString();
		str10->release();
		data->updateResouce();
		DataList_.pushBack(data);

	}

}
开发者ID:DiamondWar,项目名称:DiamondWar,代码行数:76,代码来源:AttackConfig.cpp


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