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


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

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


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

示例1: 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)
//.........这里部分代码省略.........
开发者ID:edison9888,项目名称:__graduation_project,代码行数:101,代码来源:MCItemManager.cpp

示例2: initPlayer

void GameLayer::initPlayer()
{

	CCSpriteFrameCache* frameCache = CCSpriteFrameCache::sharedSpriteFrameCache();
		frameCache->addSpriteFramesWithFile("LuckyFlying.plist");

		CCSpriteBatchNode* pigeonFlightSheet = CCSpriteBatchNode::create("LuckyFlying.png");
		addChild(pigeonFlightSheet, 3);

		CCArray* pigeonFrames = new CCArray;
		for ( int i = 2; i <= 4; i++)
		{
			CCString* filename = CCString::createWithFormat("lucky_flying_0000%d.png", i);
			CCSpriteFrame* frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(filename->getCString());
			pigeonFrames->addObject(frame);
		}

		CCAnimation* flightAnim = CCAnimation::createWithSpriteFrames(pigeonFrames, 0.1);
		pigeonSprite = CCSprite::createWithSpriteFrameName("lucky_flying_00002.png");

		//pigeonSprite->setScale(0.5f);
		pigeonSprite->setPosition(ccp(SCREEN_WIDTH/2 - 500, SCREEN_WIDTH*3 + 250));

		CCAction* flightAction = CCRepeatForever::create(CCAnimate::create(flightAnim));
		pigeonSprite->runAction(flightAction);
		pigeonFlightSheet->addChild(pigeonSprite, 3);

		schedule(schedule_selector(GameLayer::tick1), 0.10f);
		schedule(schedule_selector(GameLayer::tick2), 0.03f);

}
开发者ID:aebert1,项目名称:LBird,代码行数:31,代码来源:GameLayers.cpp

示例3: getArray

void ChooseMap::getArray(CCObject* obj){
    CCString *para = static_cast<CCString*>(obj);
    s = para->getCString();
}
开发者ID:Angusnut,项目名称:zhanqi,代码行数:4,代码来源:ChooseMap.cpp

示例4: handleRecieve

bool WinPointsUseCommand::handleRecieve(cocos2d::CCDictionary *dict)
{
    if (dict->valueForKey("cmd")->compare(WIN_POINTS_USE) != 0)
        return false;
    CCDictionary *params=_dict(dict->objectForKey("params"));
    if (!params) {
        return false;
    }
    const CCString *pStr = params->valueForKey("errorCode");
    if (pStr->compare("")!=0) {
        CCCommonUtils::flyText((_lang(pStr->getCString()).c_str()));
    }else{
        int itemId = params->valueForKey("itemId")->intValue();
        if (params->objectForKey("remainPoints")) {
            long remainPoints = params->valueForKey("remainPoints")->doubleValue();
            GlobalData::shared()->playerInfo.winPoint = remainPoints;
        }
        if(params && params->objectForKey("itemEffectObj"))
        {
            auto effectObj = _dict(params->objectForKey("itemEffectObj"));
            
            if (effectObj->objectForKey("oldStatus")) {//删除该状态的作用
                int reStatusId = effectObj->valueForKey("oldStatus")->intValue();
                if (GlobalData::shared()->statusMap.find(reStatusId) != GlobalData::shared()->statusMap.end()) {
                    GlobalData::shared()->statusMap[reStatusId] = 0;
                }
            }
            
            if (effectObj->objectForKey("effectState")) {
                auto stateDict = _dict(effectObj->objectForKey("effectState"));
                CCDictElement* element;
                CCDICT_FOREACH(stateDict, element)
                {
                    string key = element->getStrKey();
                    int effectId = atoi(key.c_str());
                    if(effectId>=PLAYER_PROTECTED_TIME1 && effectId<=PLAYER_PROTECTED_TIME5){
                        GlobalData::shared()->playerInfo.protectTimeStamp = stateDict->valueForKey(key)->doubleValue();
                        if(SceneController::getInstance()->currentSceneId == SCENE_ID_WORLD){
                            WorldMapView::instance()->m_map->updateDynamicMap(WorldController::getInstance()->selfPoint);
                        }
                    }
                    double time = stateDict->valueForKey(key)->doubleValue()/1000;
                    if (time>0) {
                        time = GlobalData::shared()->changeTime(time);
                    }
                    if (key!="startTime") {
                        GlobalData::shared()->statusMap[atoi(key.c_str())] = time;
                    }
                    auto info = ToolController::getInstance()->getToolInfoById(itemId);
                    map<int, CCDictionary* >::iterator it = ToolController::getInstance()->m_statusItems.find(info.type2);
                    CCObject* obj = element->getObject();
                    CCString* str = (CCString*)obj;
                    if(info.type==4){
                        if(it!=ToolController::getInstance()->m_statusItems.end()){
                            auto dic = it->second;
                            if(!dic->objectForKey("startTime")){
                                dic->setObject(CCString::create(CC_ITOA(WorldController::getInstance()->getTime())), "startTime");
                            }else if(key!="" && key!="startTime"){
                                dic->setObject(CCString::create(str->getCString()), "endTime");
                            }else if(key=="startTime"){
                                dic->setObject(CCString::create(str->getCString()), "startTime");
                            }
                            ToolController::getInstance()->m_statusItems[info.type2] = dic;
                        }else{
                            auto infoDic = CCDictionary::create();
                            infoDic->retain();
                            if(key!="" && key!="startTime"){
                                infoDic->setObject(CCString::create(str->getCString()), "endTime");
                            }else if(key=="startTime"){
                                infoDic->setObject(CCString::create(str->getCString()), "startTime");
                            }
                            ToolController::getInstance()->m_statusItems[info.type2] = infoDic;
                        }
                    }
                    if (effectObj->objectForKey("status")) {
                        auto arr = dynamic_cast<CCArray*>(effectObj->objectForKey("status"));
                        if (arr) {
                            CCDictionary *item = NULL;
                            for (int i=0; i<arr->count(); i++) {
                                item = _dict(arr->objectAtIndex(i));
                                auto effState = stateEffect();
                                effState.effectId = item->valueForKey("effNum")->intValue();
                                effState.value = item->valueForKey("effVal")->intValue();
                                effState.stateId = item->valueForKey("stateId")->intValue();
                                
                                if (GlobalData::shared()->effectStateMap.find(effState.effectId) != GlobalData::shared()->effectStateMap.end()) {//去除重复的stateId
                                    vector<stateEffect>::iterator it = GlobalData::shared()->effectStateMap[effState.effectId].begin();
                                    for (; it != GlobalData::shared()->effectStateMap[effState.effectId].end(); it++) {
                                        if (effState.stateId == it->stateId) {
                                            GlobalData::shared()->effectStateMap[effState.effectId].erase(it);
                                            break;
                                        }
                                    }
                                }
                                GlobalData::shared()->effectStateMap[effState.effectId].push_back(effState);
                            }
                        }
                    }
                }
            }
开发者ID:ourgames,项目名称:dc208,代码行数:100,代码来源:WinPointsUseCommand.cpp

示例5: init

bool Fish::init(FishType type)
{
    _type = type;
    CCString* animationName = CCString::createWithFormat(STATIC_DATA_STRING("fish_animation"), _type);
    CCAnimation* fishAnimation = CCAnimationCache::sharedAnimationCache()->animationByName(animationName->getCString());
    CCAnimate* fishAnimate = CCAnimate::create(fishAnimation);
    fishAnimate->setTag(k_Action_Animate);
    _fishSprite = CCSprite::create();
    this->addChild(_fishSprite);
    _fishSprite->runAction(CCRepeatForever::create(fishAnimate));
    return true;
}
开发者ID:TanCYA,项目名称:FishingJoy,代码行数:12,代码来源:Fish.cpp

示例6: init

bool CMainSelect::init()
{
    //////////////////////////////
    // 1. super init first
    if ( !CCLayer::init() )
    {
        return false;
    }
    
    this->setTouchEnabled(true);
   
    // 创建背景
    CCSize size = CCDirector::sharedDirector()->getWinSize();
    CCSprite* backgroud = CCSprite::create("mainsel/bg.png");
    backgroud->setPosition( ccp(size.width/2, size.height/2) );
    this->addChild(backgroud);
    
    // 按钮
    CCMenuItemImage *pLack = CCMenuItemImage::create("mainsel/lackNor.png",
                                                     "mainsel/lackSel.png",
                                                      this,
                                                      menu_selector(CMainSelect::lakeCallback) );
    
    CCMenuItemImage *pForest = CCMenuItemImage::create("mainsel/forestNor.png",
                                                       "mainsel/forestSel.png",
                                                       this,
                                                       menu_selector(CMainSelect::forestCallback) );
    
    CCMenuItemImage *pDesert = CCMenuItemImage::create("mainsel/desertNor.png",
                                                       "mainsel/desertSel.png",
                                                        this,
                                                        menu_selector(CMainSelect::desertCallback) );
    
    CCMenuItemImage *pPrairie = CCMenuItemImage::create("mainsel/prairieNor.png",
                                                        "mainsel/prairieSel.png",
                                                        this,
                                                        menu_selector(CMainSelect::prairieCallback) );
    
    pLack->setPosition(    ccp(171, 437) );
    pForest->setPosition(  ccp(539, 401) );
    pDesert->setPosition(  ccp(864, 411) );
    pPrairie->setPosition( ccp(392, 208) );
    
   
    CCMenu* pMenu = CCMenu::create(pLack, pForest, pDesert, pPrairie, NULL);
    pMenu->setPosition( CCPointZero );
    this->addChild(pMenu, 1);
    
    // 创建sprite sheet
    CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("mainsel/jingyu.plist");
    CCSpriteBatchNode *spriteSheet = CCSpriteBatchNode::create("mainsel/jingyu.png");
    this->addChild(spriteSheet);
    
    // 创建对象
    CCSprite *sprite = CCSprite::createWithSpriteFrameName("jingyu01.png");        
    sprite->setPosition(ccp(920,220));
    spriteSheet->addChild(sprite, 0);
          
    CCArray *arrShang = CCArray::create(); // 动画帧数组
    for(int i=1; i<=8; ++i)
    {     
        CCString *name = CCString::createWithFormat("jingyu%02d.png", i);
        arrShang->addObject(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(name->getCString()));
    }
    
    CCArray *arrPeng = CCArray::create(); // 动画帧数组
    for(int i=9; i<=11; ++i)
    {
        CCString *name = CCString::createWithFormat("jingyu%02d.png", i);
        arrPeng->addObject(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(name->getCString()));
    }
    CCArray *arrPengRev = CCArray::createWithArray(arrPeng);
    arrPengRev->reverseObjects();
    arrPeng->addObjectsFromArray(arrPengRev);
    
    CCFiniteTimeAction *delay = CCDelayTime::create(1);

    CCAnimate* anShang = CCAnimate::create(CCAnimation::createWithSpriteFrames(arrShang, 0.25));
    CCAnimate* anPeng  = CCAnimate::create(CCAnimation::createWithSpriteFrames(arrPeng, 0.15));
    sprite->runAction(CCRepeatForever::create((CCActionInterval*)CCSequence::create(anShang, delay, anPeng,anPeng, anPeng, anPeng, anPeng, anShang->reverse(),delay,delay,delay,NULL)));
    return true;
}
开发者ID:silvonli,项目名称:AnimalStudy,代码行数:82,代码来源:MainSelectScene.cpp

示例7: getConfigOfHero

configHeroItem*  CData::getConfigOfHero(int tempid)
{
    
    if(m_config_hero_dic->count() < 1)
    {
     //   const char * path=CCFileUtils::sharedFileUtils()->fullPathForFilename("hero.json").c_str();
//        ifstream ifs;
//        ifs.open(path);
//        assert(ifs.is_open());
        
        Json::Reader reader;
        Json::Value root;
        Json::Value items;
        
        Json::Value::Members members;
        
        //        Json::Value::iterator it;
        Json::Value::Members::iterator it;
        
        string path = CCFileUtils::sharedFileUtils()->fullPathForFilename("hero.json");
        CCString* str = CCString::createWithContentsOfFile(path.c_str());
        
        if(reader.parse(str->getCString(), root)){
            
            members = root.getMemberNames();
            it = members.begin();
            while (it != members.end()) {
                
                items = root[std::string(*it)];
                
                configHeroItem * item= new configHeroItem();
                char inttostr[20]="";
                sprintf(inttostr, "%d",tempid);
                item->DexGrowth = items["DexGrowth"].asInt();//" : 970,
                item->StrGrowth = items["StrGrowth"].asInt();//" : 2925,
                item->VitGrowth = items["VitGrowth"].asInt();//" : 2100,
                item->WisGrowth = items["WisGrowth"].asInt();//" : 1026,
                item->attrType = items["attrType"].asInt();//" : 3,
                item->baseQuality = items["baseQuality"].asInt();//" : 5,
                item->coin = items["coin"].asInt();//" : 50000,
                item->descript = items["descript"].asString();//" : "会释放邪恶法术的士兵,攻击力较高防御较低,擅长远程群体攻击。",
                item->icon = items["icon"].asInt();//" : 378,
                item->id = items["id"].asInt();// : 35107,
                item->level = items["level"].asInt();//" : 103,
                item->nickname = items["nickname"].asString();//" : "蛮夷邪士",
                item->ordSkill = items["ordSkill"].asInt();//" : 5107,
                item->resourceid = items["resourceid"].asInt();//" : 5107,
                item->skill = items["skill"].asInt();//" : 710303,
                item->soulcount = items["soulcount"].asInt();//" : 100,
                item->soulrequired = items["soulrequired"].asInt();//" : 41004094,
                item->type = items["type"].asInt();//" : 220000,
                item->xy = items["xy"].asInt();//" : -1

                m_config_hero_dic->setObject(item, item->id);
                
//                item->bodytype=items["bodyType"].asInt();
//                item->name=items["name"].asString();
//                item->pinzhi=items["baseQuality"].asInt();
//                item->des=items["description"].asString();
//                item->tempid = items["id"].asInt();
//                item->bodytype = items["bodytype"].asInt();
//                
//                m_config_goods_dic->setObject(item, item->tempid);
                
                it++;
            }
            
//            ifs.close();
            
        }
        
    }
    
    
    return (configHeroItem*)m_config_hero_dic->objectForKey(tempid);
    
}
开发者ID:noahzaozao,项目名称:mud7client,代码行数:77,代码来源:CData.cpp

示例8: initAction

void Runner::initAction()
{
    //init runningAction
    CCArray *animFrames = CCArray::create();
    for (int i = 0; i < 8; i++)
    {
        CCString* name = CCString::createWithFormat("runner%d.png",i);
        CCSpriteFrame* frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(name->getCString());
        animFrames->addObject(frame);
    }
    CCAnimation *animation = CCAnimation::createWithSpriteFrames(animFrames, 0.1);
    m_actionRunning =CCRepeatForever::create(CCAnimate::create(animation));
    m_actionRunning->retain();

    // init jumpUpAction
    animFrames = CCArray::create();
    for (int i=0; i<4; i++)
	{
        CCString* name = CCString::createWithFormat("runnerJumpUp%d.png",i);
        CCSpriteFrame* frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(name->getCString());
        animFrames->addObject(frame);
    }
    animation = CCAnimation::createWithSpriteFrames(animFrames, 0.2);
	m_actionJumpUp = CCAnimate::create(animation);
	m_actionJumpUp->retain();

    // init jumpDownAction
    animFrames->removeAllObjects();
    for (int i=0; i<2; i++)
	{
        CCString *name = CCString::createWithFormat("runnerJumpDown%d.png",i);
        CCSpriteFrame *frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(name->getCString());
        animFrames->addObject(frame);
    }
    animation = CCAnimation::createWithSpriteFrames(animFrames, 0.3);
	m_actionJumpDown = CCAnimate::create(animation);
	m_actionJumpDown->retain();

    // init crouchAction
    animFrames->removeAllObjects();
    for (int i=0; i<1; i++)
	{
        CCString *name = CCString::createWithFormat("runnerCrouch%d.png",i);
        CCSpriteFrame *frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(name->getCString());
        animFrames->addObject(frame);
    }
    animation = CCAnimation::createWithSpriteFrames(animFrames, 0.3);
	m_actionCrouch = CCAnimate::create(animation);
	m_actionCrouch->retain();
}
开发者ID:LiYuandong,项目名称:Parkour,代码行数:50,代码来源:Runner.cpp

示例9: initWithImageData

bool GAFAsset::initWithImageData(const std::string& jsonPath)
{
		
	GAFData aConfigData;
	std::string fp = CCFileUtils::sharedFileUtils()->fullPathForFilename(jsonPath.c_str());
	
	aConfigData.delete_data = true;
	aConfigData.ptr = CCFileUtils::sharedFileUtils()->getFileData(fp.c_str(), "rb", &aConfigData.size);
	if (!aConfigData.ptr)
	{
		CCLOGERROR("Can not get data from json file : %s", jsonPath.c_str());
		return NULL;
	}

	if (!aConfigData.getBytes())
	{
		CCLOGWARN("can not init GAFAsset - invalid anImageData");
		return false;
	}
	
	CCDictionary* configDictionary = CCJSONConverter::sharedConverter()->dictionaryFrom( (const char *)aConfigData.getBytes());
	
	CCString *versionNode               = (CCString*)configDictionary->objectForKey(kVersionKey);
	
	if (!isAssetVersionPlayable(versionNode->getCString()))
	{
		return false;
	}
	CCArray *animationConfigFrames      = (CCArray *)configDictionary->objectForKey(kAnimationConfigFramesKey);
	CCArray *interactionObjectNodes     = (CCArray *)configDictionary->objectForKey(kInteractionObjectsKey);
	CCArray *standObjectsNodes          = (CCArray *)configDictionary->objectForKey(kStandObjectsKey);
	CCArray *textureAtlasNode           = (CCArray *)configDictionary->objectForKey(kTextureAtlasKey);
	CCArray *animationSequences         = (CCArray *)configDictionary->objectForKey(kAnimationSequencesKey);
	
	CCDictionary *objectNodes           = (CCDictionary *)configDictionary->objectForKey(kAnimationObjectsKey);
	CCDictionary *masksNodes            = (CCDictionary *)configDictionary->objectForKey(kAnimationMasksKey);
	CCDictionary *namedPartsNodes       = (CCDictionary *)configDictionary->objectForKey(kAnimationNamedPartsKey);

	
	if (!animationConfigFrames || !textureAtlasNode|| !objectNodes)
	{
		CCLOGERROR("Error while creating GAFAsset. Required subnodes in dictionary are missing.");
		return false;
	}
	
	CC_SAFE_RELEASE(_textureAtlas);
	
	if (!textureAtlasNode->count())
	{
		return false;
	}

	CCDictionary * atlasDictionary = (CCDictionary *)textureAtlasNode->objectAtIndex(0);
	float atlasScale = atlasScaleFromAtlasConfig(atlasDictionary);
	for (int i = 1; i < textureAtlasNode->count(); ++i)
	{
		CCDictionary * a = (CCDictionary *)textureAtlasNode->objectAtIndex(i);
		float as = atlasScaleFromAtlasConfig(a);
		if ( fabs(atlasScale - _currentDeviceScale) > fabs(as - _currentDeviceScale))
		{
			atlasDictionary = a;
			atlasScale = as;
		}
	}
	
	_usedAtlasContentScaleFactor = atlasScale;
	CCArray * atlasesInfo = (CCArray *)atlasDictionary->objectForKey(kAtlasInfoKey);
	if (!atlasesInfo)
	{
		CCLOGERROR("Error while creating GAFAsset.atlasesInfo subnode is missing in atlasDictionary.");
		return false;
	}
	
	_textureAtlas = GAFTextureAtlas::create(fp.c_str(), atlasDictionary);
	if (!_textureAtlas)
	{
		CCLOGERROR("Failed to initialize GAFAsset. GAFTextureAtlas could not be created.");
		return false;
	}
	CC_SAFE_RETAIN(_textureAtlas);
	
	if (_objects != objectNodes)
	{
		CC_SAFE_RELEASE(_objects);
		_objects = objectNodes;
		CC_SAFE_RETAIN(_objects);
	}
	
	if (_masks != masksNodes)
	{
		CC_SAFE_RELEASE(_masks);
		_masks	  = masksNodes;
		CC_SAFE_RETAIN(_masks);
	}
	
	if (_namedParts != namedPartsNodes)
	{
		CC_SAFE_RELEASE(_namedParts);
		_namedParts	  = namedPartsNodes;
		CC_SAFE_RETAIN(_namedParts);
//.........这里部分代码省略.........
开发者ID:digitalassetgroup,项目名称:-BIBS-Game,代码行数:101,代码来源:GAFAsset.cpp

示例10: preLoadAnimations

void AnimationManager::preLoadAnimations()
{
    CCAnimation* pAnimation = CCAnimationCache::sharedAnimationCache()->animationByName("hero_idle");
    if (pAnimation == NULL) {
        pAnimation = CCAnimation::create();
        for (int i=0; i<4; i++)
        {
            CCString* pFileName = CCString::createWithFormat("idle/o%04d.png", i);
            pAnimation->addSpriteFrameWithFileName(pFileName->getCString());
        }
        pAnimation->setRestoreOriginalFrame(true);
        pAnimation->setDelayPerUnit(0.2f);    // 必须设置这个,要不就不会播放
        pAnimation->setLoops(1);
        CCAnimationCache::sharedAnimationCache()->addAnimation(pAnimation, "hero_idle");
    }
    pAnimation = CCAnimationCache::sharedAnimationCache()->animationByName("hero_run");
    if (pAnimation == NULL) {
        pAnimation = CCAnimation::create();
        for (int i=0; i<4; i++)
        {
            CCString* pFileName = CCString::createWithFormat("run/m%04d.png", i);
            pAnimation->addSpriteFrameWithFileName(pFileName->getCString());
        }
        pAnimation->setRestoreOriginalFrame(true);
        pAnimation->setDelayPerUnit(0.1f);    // 必须设置这个,要不就不会播放
        pAnimation->setLoops(1);
        CCAnimationCache::sharedAnimationCache()->addAnimation(pAnimation, "hero_run");
    }
    pAnimation = CCAnimationCache::sharedAnimationCache()->animationByName("hero_atk_a");
    if (pAnimation == NULL) {
        int iKeyFrame = 4;
        pAnimation = CCAnimation::create();
        for (int i=1; i<=4; i++)
        {
            CCString* pFileName = CCString::createWithFormat("skill/a%04d.png", i);
            pAnimation->addSpriteFrameWithFileName(pFileName->getCString());
            if (i == iKeyFrame) {
                for (int k=0; k<2; k++) {
                    pAnimation->addSpriteFrameWithFileName(pFileName->getCString());
                }
            }
        }
        pAnimation->setRestoreOriginalFrame(true);
        pAnimation->setDelayPerUnit(0.1f);    // 必须设置这个,要不就不会播放
        pAnimation->setLoops(1);
        CCAnimationCache::sharedAnimationCache()->addAnimation(pAnimation, "hero_atk_a");
    }
    pAnimation = CCAnimationCache::sharedAnimationCache()->animationByName("hero_atk_b");
    if (pAnimation == NULL) {
        int iKeyFrame = 2;
        pAnimation = CCAnimation::create();
        for (int i=1; i<=4; i++)
        {
            CCString* pFileName = CCString::createWithFormat("skill/b%04d.png", i);
            pAnimation->addSpriteFrameWithFileName(pFileName->getCString());
            if (i == iKeyFrame) {
                for (int k=0; k<2; k++) {
                    pAnimation->addSpriteFrameWithFileName(pFileName->getCString());
                }
            }
        }
        pAnimation->setRestoreOriginalFrame(true);
        pAnimation->setDelayPerUnit(0.1f);    // 必须设置这个,要不就不会播放
        pAnimation->setLoops(1);
        CCAnimationCache::sharedAnimationCache()->addAnimation(pAnimation, "hero_atk_b");
    }
    pAnimation = CCAnimationCache::sharedAnimationCache()->animationByName("hero_atk_c");
    if (pAnimation == NULL) {
        int iKeyFrame = 3;
        pAnimation = CCAnimation::create();
        for (int i=1; i<=4; i++)
        {
            CCString* pFileName = CCString::createWithFormat("skill/c%04d.png", i);
            pAnimation->addSpriteFrameWithFileName(pFileName->getCString());
            if (i == iKeyFrame) {
                for (int k=0; k<2; k++) {
                    pAnimation->addSpriteFrameWithFileName(pFileName->getCString());
                }
            }
        }
        pAnimation->setRestoreOriginalFrame(true);
        pAnimation->setDelayPerUnit(0.1f);    // 必须设置这个,要不就不会播放
        pAnimation->setLoops(1);
        CCAnimationCache::sharedAnimationCache()->addAnimation(pAnimation, "hero_atk_c");
    }
    pAnimation = CCAnimationCache::sharedAnimationCache()->animationByName("hero_atk_d");
    if (pAnimation == NULL) {
        int iKeyFrame = 4;
        pAnimation = CCAnimation::create();
        for (int i=1; i<=4; i++)
        {
            CCString* pFileName = CCString::createWithFormat("skill/d%04d.png", i);
            pAnimation->addSpriteFrameWithFileName(pFileName->getCString());
            if (i == iKeyFrame) {
                for (int k=0; k<2; k++) {
                    pAnimation->addSpriteFrameWithFileName(pFileName->getCString());
                }
            }
        }
        pAnimation->setRestoreOriginalFrame(true);
//.........这里部分代码省略.........
开发者ID:zhouxj6112,项目名称:HelloWorld-cocos2d-x-2.2.3,代码行数:101,代码来源:AnimationManager.cpp

示例11: beginDrawLine


//.........这里部分代码省略.........
                if (linelist[j].endIndex == end && linelist[j].kind != LineKind) {
                    for (int m = 0; m < linelist.size(); m ++) {
                        if (linelist[m].kind == linelist[j].kind) {
                            linelist1.push_back(linelist[m]);
                        }
                    }
                    for (int n = 0; n < linelist1.size(); n ++) {
                        if (linelist1[n].endIndex == end) {
                            lineTiem a = linelist1[n];
                            a.pic -> setVisible(false);
                            while (1) {
                                for (int k = 0; k < linelist1.size(); k++) {
                                    if (linelist1[k].beginIndex == end) {
                                        linelist1[k].pic -> setVisible(false);
                                        end = linelist1[k].endIndex;
                                        continue;
                                    }
                                }
                                break;
                            }
                        }
                    }
                }
            }
        }
    }
    //按照条件设置部分线条为隐藏
    for (int i = 0; i < linelist.size(); i ++) {
        //回滚原来的线条,会删除图片
        if (linelist[i].beginIndex == sencond_box && linelist[i].endIndex == first_box && LineKind == linelist[i].kind) {
            vector<lineTiem>linelist1;
            for (int j = 0 ; j < linelist.size(); j ++) {
                if (linelist[j].beginIndex == linelist[i].beginIndex && linelist[j].endIndex == linelist[i].endIndex) {
                    continue;
                }
                else
                    linelist1.push_back(linelist[j]);
            }
            linelist[i].pic -> removeFromParentAndCleanup(true);
            linelist.clear();
            linelist = linelist1;
            linelist1.clear();
            first_box = sencond_box;
            return;
        }
        //不同颜色尾部相交
        if (linelist[i].endIndex == sencond_box && LineKind != linelist[i].kind) {
            lineTiem model = linelist[i];
            model.pic -> setVisible(false);
            int next = model.endIndex;
            while (1) {
                for (int j = 0; j < linelist.size(); j ++) {
                    if (linelist[j].beginIndex == next && linelist[j].kind == linelist[i].kind) {
                        linelist[j].pic -> setVisible(false);
                        next = linelist[j].endIndex;
                        continue;
                    }
                }
                break;
            }
        }
    }
    CCString str;
    int t = drawLineKind;
    if (LineKind == StarIcon) {
        t = 4;
    }
    if (LineKind == Box_5w) {
        t = 5;
    }
    str.initWithFormat("line/link_line_%d.png", t);
    auto line = CCSprite::createWithSpriteFrameName(str.getCString());
    
    if (x == 0 && y < 0) {
        line -> setRotation(90);
    }
    if (x == 0 && y > 0) {
        line -> setRotation(90);
    }
    line -> setScaleY(0.8*size);
    line -> setScaleX(0.9*size);
    line -> setPosition(point);
    CCString str1;
    lineTiem item;
    item.pic = line;
    item.kind = LineKind;
    item.beginIndex = first_box;
    item.endIndex = sencond_box;
    item.haveNext = false;
    item.drawKind = drawLineKind;
    for (int i = 0; i < linelist.size(); i ++) {
        if (linelist[i].kind == LineKind && !linelist[i].haveNext) {
            linelist[i].haveNext = true;
        }
    }
    linelist.push_back(item);
    lineNode -> addChild(line);
    first_box = sencond_box;
    showSharder();
}
开发者ID:anzhongliu,项目名称:SmallGame_Cocos2dx,代码行数:101,代码来源:GameNewLinker.cpp

示例12: initWithText

bool GameButton::initWithText(const char * text, bool isBig)
{
    if (!CCSprite::init()) {
        return false;
    }
    CCString* btnFrame = (isBig) ? CCString::create("button_big.png") : CCString::create("button_small.png");
    int fSize = 18 * Utils::getArtScaleFactor();
    this->setDisplayFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(btnFrame->getCString()));
    CCLabelTTF *label = CCLabelTTF::create(text, CCString::createWithFormat("%s.ttf",FONT_MAIN)->getCString(), fSize + isBig * fSize);
    label->setPosition(ccp(this->getContentSize().width/2,this->getContentSize().height/2));
    this->addChild(label,1);
    
    CCLabelTTF *labelShadow = CCLabelTTF::create(text, CCString::createWithFormat("%s.ttf",FONT_MAIN)->getCString(), fSize + isBig * fSize);
    labelShadow->setPosition(ccp(this->getContentSize().width/2 - (2 + isBig * 2),this->getContentSize().height/2));
    labelShadow->setColor(ccBLACK);
    labelShadow->setOpacity(150);
    this->addChild(labelShadow,0);
    
    this->setScale(Utils::getScale());

    return true;
}
开发者ID:juciefreitas,项目名称:android-cocos2dx,代码行数:22,代码来源:GameButton.cpp

示例13: onButton

void RPGMapItemsMenuLayer::onButton(cocos2d::CCObject *pSender, CCControlEvent event)
{
    SimpleAudioEngine::sharedEngine()->playEffect("audio_effect_btn.wav");
    
    CCControlButton *itemBtn = (CCControlButton*)pSender;
    
    if(itemBtn->getTag() == kRPGMapItemsMenuLayerTagBtnDiscard)
    {
//        CCLog("丢弃道具");
        
        RPGResultsLogic::discardItems(this->m_db, this->m_selectedItems->m_dataId);
        
        this->getParent()->removeChildByTag(kRPGMapSceneLayerTagChoicePlayerMenuLayerBg, true);
        this->getParent()->removeChildByTag(kRPGMapSceneLayerTagChoicePlayerMenuLayer, true);
        this->getParent()->removeChildByTag(kRPGMapItemsMenuLayerTagBtnDiscard, true);
        this->setVisible(true);
        
        this->loadItemsData();
    }
    else
    {
        for (int i = 0; i < this->m_itemsList->count(); i++)
        {
            //判断选中道具
            RPGExistingItems *itemsData = (RPGExistingItems*)this->m_itemsList->objectAtIndex(i);
            if(itemBtn->getTag() == itemsData->m_dataId)
            {
                this->m_selectedItems = itemsData;
                break;
            }
        }
        
        //因为动态获取地图的大小会导致了菜单层显示错位,所以定死了
        float width = 960;
        float height = 640;
        
        //临时背景
        CCTMXTiledMap *mainBg = CCTMXTiledMap::create(CCString::createWithFormat("map_menu3_%s.tmx", CCUserDefault::sharedUserDefault()->getStringForKey(GAME_STYLE).c_str())->getCString());
        mainBg->setPosition(ccp(CCDirector::sharedDirector()->getWinSize().width / 2, CCDirector::sharedDirector()->getWinSize().height / 2));
        mainBg->setAnchorPoint(ccp(0.5, 0.5));
        mainBg->setTag(kRPGMapSceneLayerTagChoicePlayerMenuLayerBg);
        this->getParent()->addChild(mainBg);
        
        CCString *title = CCString::createWithFormat(((CCString*)this->m_stringList->objectForKey("menu_items_choice"))->getCString(), this->m_selectedItems->m_name.c_str());
        RPGMapChoicePlayerMenuLayer *choicePlayer = RPGMapChoicePlayerMenuLayer::create(this->m_db, title, this, callfuncO_selector(RPGMapItemsMenuLayer::onChoicePlayer), width, height);
        choicePlayer->setTag(kRPGMapSceneLayerTagChoicePlayerMenuLayer);
        this->getParent()->addChild(choicePlayer);
        
        if(this->m_selectedItems->m_type != 3)
        {
//            CCLog("非道具不可以使用");
            choicePlayer->setHidden(true);
        }
        
        CCString *btnDiscardText = CCString::createWithFormat(((CCString*)this->m_stringList->objectForKey("menu_items_discard"))->getCString(), this->m_selectedItems->m_name.c_str());
        CCControlButton *btnDiscard = CCControlButton::create(btnDiscardText->getCString(), "Arial", 24);
        btnDiscard->setPosition(ccp(CCDirector::sharedDirector()->getWinSize().width / 2, 250));
        btnDiscard->setTag(kRPGMapItemsMenuLayerTagBtnDiscard);
        btnDiscard->addTargetWithActionForControlEvents(this, cccontrol_selector(RPGMapItemsMenuLayer::onButton), CCControlEventTouchUpInside);
        this->getParent()->addChild(btnDiscard);
        
        this->setVisible(false);
    }
    
}
开发者ID:ChinaiOS,项目名称:OzgGameRPG,代码行数:65,代码来源:RPGMapItemsMenuLayer.cpp

示例14: 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));
    }
}
开发者ID:edison9888,项目名称:__graduation_project,代码行数:75,代码来源:MCItemManager.cpp

示例15: sureBuyCallEffect

void GameLayer_GoldMarket::sureBuyCallEffect(int i,int iType){

	 CCPoint point;
	switch (i) {
	case 1:
		point.x =105;
		point.y =725;
		break;
	case 2:
		point.x =105;
		point.y =625;
		break;
	case 3:
		point.x =105;
		point.y =525;
		break;
	case 4:
		point.x =105;
		point.y =425;
		break;
	case 5:
		point.x =105;
		point.y =325;
		break;
	default:
		break;
	}
	CCSize visableSize = CCDirector::sharedDirector()->getVisibleSize();
	CCPoint goldPosition = ccp(visableSize.width/2-60,visableSize.height-45);

	char str1[100]={0};
	switch(iType)
	{
	case 1:
		sprintf(str1,"./CocoStudioResources/DayLogin/WhiteGold.png");
		break;
	case 2:
		sprintf(str1,"./CocoStudioResources/DayLogin/WhiteJewel.png");
	default:
		break;
	}
	char str2[100]={0};
	switch(iType)
	{
	case 1:
		sprintf(str2,"./CocoStudioResources/DayLogin/Star1.png");
		break;
	case 2:
		sprintf(str2,"./CocoStudioResources/DayLogin/jewelStar1.png");
		break;
	default:
		break;
	}
	char str3[100]={0};
	switch(iType)
	{
	case 1:
		sprintf(str3,"./CocoStudioResources/DayLogin/FlyGold.png");
		break;
	case 2:
		sprintf(str3,"./CocoStudioResources/DayLogin/FlyJewel.png");
		break;
	default:
		break;
	}
	//最后亮一下的金币.
	CCSprite* lightGold1 = CCSprite::create(str1);
	this->addChild(lightGold1,10);
	lightGold1->setPosition(goldPosition);
	lightGold1->setVisible(false);
	CCSequence* lightGoldAction1 = CCSequence::create(CCShow::create() ,CCFadeOut::create(0.5),NULL);
	CCSprite* lightGold2 = CCSprite::create(str1);
	this->addChild(lightGold2,10);
	lightGold2->setPosition(goldPosition);
	lightGold2->setVisible(false);
	CCSequence* lightGoldAction2 = CCSequence::create(CCShow::create() ,CCFadeOut::create(0.5),NULL);
	CCSprite* lightGold3 = CCSprite::create(str1);
	this->addChild(lightGold3,10);
	lightGold3->setVisible(false);
	CCSequence* lightGoldAction3 = CCSequence::create(CCShow::create() ,CCFadeOut::create(0.5),NULL);
	lightGold3->setPosition(goldPosition);

	//钱的闪光.
	CCString str;
	CCAnimation* pAni = CCAnimation::create();
	for (int i=1; i<=3; i++) {
		if (iType==1)
			str.initWithFormat("./CocoStudioResources/DayLogin/Star%d.png",i);
		else if(iType==2)
			str.initWithFormat("./CocoStudioResources/DayLogin/jewelStar%d.png",i);
		pAni->addSpriteFrameWithFileName(str.getCString());
	}
	pAni->setDelayPerUnit(0.3f/3.f);
	pAni->setLoops(1);


	//金币爆炸效果.
	CCSprite* goldEffect1 = CCSprite::create();
	goldEffect1->setVisible(false);
	auto *pic_1 = CCSprite::create(str2);
//.........这里部分代码省略.........
开发者ID:anzhongliu,项目名称:SmallGame_Cocos2dx,代码行数:101,代码来源:GameLayer_GoldMarket.cpp


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