CCArray * GAFAsset::objectStatesFromConfigFrame(CCDictionary * configFrame)
{
	if (!configFrame)
	{
		return NULL;
	}
	CCDictionary * stateNodes = (CCDictionary *) configFrame->objectForKey(kFrameStateKey);
	if (!stateNodes)
	{
		return NULL;
	}
    CCArray *states = CCArray::createWithCapacity(stateNodes->count());
	
	CCDictElement* pElement = NULL;
    CCDICT_FOREACH(stateNodes, pElement)
    {
		CCDictionary * stateDictionary = (CCDictionary *)pElement->getObject();
		GAFSubobjectState * state = GAFSubobjectState::createWithStateDictionary(stateDictionary, pElement->getStrKey());
		if (state)
		{
			states->addObject(state);
		}
		else
		{
			CCLOGINFO("GAFSubobjectState cannot be created. Ignoring.");
		}
	}
Beispiel #2
0
bool BattleMap::f_load_entile()
{

do 
{
	b2CircleShape circle; 

	b2BodyDef ballBodyDef;					
	ballBodyDef.type = b2_dynamicBody;  	 
	circle.m_radius = 16.0/PTM_RATIO;  

	b2FixtureDef ballShapeDef;				
	ballShapeDef.shape = &circle;  
	ballShapeDef.density = 1.0f;  
	ballShapeDef.friction = 1.0f;  
	ballShapeDef.restitution = 0.0f;  
	ballShapeDef.isSensor = true;				// 将碰撞形状改为sensor不会提高多少效率却会破坏map原本事件机制。
	
	//// b2body准备工作
	//////////////////////////////////////////////////////////////////////////
	CCSize ts = m_tilemap->getTileSize();
	b2PolygonShape boxShape;
	float hbw = (ts.width-1)/( PTM_RATIO * 4);
	float hbh = (ts.height-1)/( PTM_RATIO);
	hbh *= 1.2;
	boxShape.SetAsBox(hbw,hbh,b2Vec2(0,hbh),0);


	CCDictElement* cde = NULL;
	CCDICT_FOREACH(m_itemlist,cde){
		EChesses* t_ec = (EChesses*) cde->getObject();
		
		t_ec->initFiles("grossinis_sister2.png");
		CCPoint d = m_getViewc(t_ec->pos);

		t_ec->m_sprite->setAnchorPoint(ccp(0,0));
		t_ec->b_Re = true;
		addChild(t_ec->m_sprite);

		ballBodyDef.position.Set((dtx+d.x)/PTM_RATIO, (d.y+dty)/PTM_RATIO);  
		_body = _world->CreateBody(&ballBodyDef);  
		_body->SetFixedRotation(true);
		_body->CreateFixture(&ballShapeDef); 

		t_ec->m_body = _body;
		_body->SetUserData(t_ec);			

		b2FixtureDef boxFixtureDef;				
		boxFixtureDef.shape = &boxShape;
		boxFixtureDef.density = 1;
		boxFixtureDef.filter.categoryBits = 0x0002;
		boxFixtureDef.filter.maskBits = 0x0001;
		boxFixtureDef.isSensor = true;

		_body->CreateFixture(&boxFixtureDef);
	}
	// EChesses in BattleMap has its own logic, so a logic based on sensor is no longer needed.

	return true;
} while (0);
void YHLanguageManager::addTexts(cocos2d::CCDictionary * dict)
{
    CCDictElement * e = nullptr;
    CCDICT_FOREACH(dict, e)
    {
        m_dict->setObject(e->getObject(), e->getStrKey());
    }
void CCPrettyPrinter::visit(const CCDictionary *p)
{
    _result += "\n";
    _result += _indentStr;
    _result += "<dict>\n";
    
    setIndentLevel(_indentLevel+1);
    CCDictElement* element;
    bool bFirstElement = true;
    char buf[1000] = {0};
    CCDICT_FOREACH(p, element)
    {
        if (!bFirstElement) {
            _result += "\n";
        }
        sprintf(buf, "%s%s: ", _indentStr.c_str(),element->getStrKey());
        _result += buf;
        CCPrettyPrinter v(_indentLevel);
        element->getObject()->acceptVisitor(v);
        _result += v.getResult();
        bFirstElement = false;
    }
    setIndentLevel(_indentLevel-1);
    
    _result += "\n";
    _result += _indentStr;
    _result += "</dict>";
}
bool CCDictionarySaver::saveDictionary(CCDictionary* pDict, xmlNodePtr node)
{
    do
    {
        xmlNodePtr dict_node = xmlNewNode(NULL, DICT_NODE_DICT);
        CC_BREAK_IF(!dict_node);
        
        CC_BREAK_IF(!xmlAddChild(node, dict_node));
        
        CCDictElement* pElem;
        CCDICT_FOREACH(pDict, pElem)
        {
            saveKey(pElem->getStrKey(), dict_node);
            
            CCObject* obj = pElem->getObject();

            if (dynamic_cast<CCString*>(obj))
            {
                CCString* s = dynamic_cast<CCString*>(obj);
                CC_BREAK_IF(!saveString(s->getCString(), dict_node));
            }
            else if (dynamic_cast<CCDictionary*>(obj))
            {
                CC_BREAK_IF(!saveDictionary(dynamic_cast<CCDictionary*>(obj), dict_node));
            }
            else if (dynamic_cast<CCArray*>(obj))
            {
                CC_BREAK_IF(!saveArray(dynamic_cast<CCArray*>(obj), dict_node));
            }
        }
        return true;
    } while (false);
void StatusPush::handleResponse(__Dictionary* dict)
{
    if (!dict)
    {
        return;
    }
    __Dictionary* params = _dict(dict->objectForKey("params"));

    if (params->objectForKey("oldStatus")) {//删除该状态的作用
        int reStatusId = params->valueForKey("oldStatus")->intValue();
        if (GlobalData::shared()->statusMap.find(reStatusId) != GlobalData::shared()->statusMap.end()) {
            GlobalData::shared()->statusMap[reStatusId] = 0;
        }
    }
//    int tempTime = 0;
    if (params->objectForKey("effectState")) {
        auto stateDict = _dict(params->objectForKey("effectState"));
        CCDictElement* element;
        CCDICT_FOREACH(stateDict, element)
        {
            string key = element->getStrKey();
//            int effectId = atoi(key.c_str());

            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())] = -1;//time;
//                tempTime = time;
            }
            map<int, CCDictionary* >::iterator it = ToolController::getInstance()->m_statusItems.find(100);
            CCObject* obj = element->getObject();
            CCString* str = (CCString*)obj;

            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[100] = 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[100] = infoDic;
            }
            

            ToolController::getInstance()->checkMaincityCustom();

        }
void CCJSONConverter::convertDictionaryToJson(CCDictionary *dictionary, cJSON *json)
{
    CCDictElement * pElement = NULL;
    CCDICT_FOREACH(dictionary, pElement){
        CCObject * obj = pElement->getObject();
        cJSON * jsonItem = getObjJson(obj);
        cJSON_AddItemToObject(json, pElement->getStrKey(), jsonItem);
    }
CCBAnimationManager::~CCBAnimationManager()
{
    CCDictElement *pElement = NULL;
    CCDICT_FOREACH(mNodeSequences, pElement)
    {
        CCNode *node = (CCNode*)pElement->getIntKey();
        node->release();
    }
void CCBProxy::releaseMembers(){
	CCDictElement *e;
	CCNode *n;
	CCDICT_FOREACH(_memVars, e){
		n = (CCNode *)e->getObject();
		n->removeFromParentAndCleanup(true);
		n->autorelease();
	}
void CCProfiler::displayTimers()
{
    CCDictElement* pElement = NULL;
    CCDICT_FOREACH(m_pActiveTimers, pElement)
    {
        CCProfilingTimer* timer = (CCProfilingTimer*)pElement->getObject();
        CCLog("%s", timer->description());
    }
Beispiel #11
0
CCDictionary* CCTextureCache::snapshotTextures()
{ 
    CCDictionary* pRet = new CCDictionary();
    CCDictElement* pElement = NULL;
    CCDICT_FOREACH(m_pTextures, pElement)
    {
        pRet->setObject(pElement->getObject(), pElement->getStrKey());
    }
void YHEffectFactory::addEffectDefiner(CCDictionary * dict)
{
	CCDictElement * e = NULL;
	CCDICT_FOREACH(dict, e)
	{
		YHEffectDefiner * definer = new YHEffectDefiner((CCDictionary *)e->getObject());
		definer->autorelease();
		addEffectDefiner(e->getStrKey(), definer);
	}
Beispiel #13
0
void BZGameMenu::onUpdate()
{
	CCDictElement* pElement = NULL;
	CCDICT_FOREACH(_bars, pElement)
	{
		BZGameMenuBar* pbar = (BZGameMenuBar*)pElement->getObject();
		_Assert(pbar);
		pbar->onUpdate();
	}
Beispiel #14
0
void BBTouchManager::saveTouches()
{
	CCDictElement* pElement;
	BBTouchInfo* touchInfo = BBTouchInfo::create();
	
	CCDICT_FOREACH(m_pTouches, pElement)
	{
		CCTouch* v = (CCTouch*)pElement->getObject();
		touchInfo->touches.push_back(v->getLocation());
	}
CCArray* MultiplayerGameState::getAllOpponents()
{
    if (_opponentsSprite == NULL || _opponentsSprite->count() <= 0) return NULL;
    CCArray* opponents = CCArray::createWithCapacity(_opponentsSprite->count());

    CCDictElement* dictElement = NULL;
    CCDICT_FOREACH(_opponentsSprite, dictElement)
    {
        opponents->addObject((Opponent*)dictElement->getObject());
    }
Beispiel #16
0
GameEntity::~GameEntity()
{
    CCLOG("GameEntity destroy");
    
//    CC_SAFE_RELEASE(m_view);
    
    CCDictElement* pElement = NULL;
    CCDICT_FOREACH(m_components,pElement){
        Component* component=(Component*)pElement->getObject();
        component->cleanupMessages();
    }
Beispiel #17
0
void Animal::clean(){
	this->finishCurAction();
	this->stopAllActions();
	this->getObserver()->finish();
	CCDictElement* pElement = NULL;
	CCDICT_FOREACH(moves, pElement)
{
    int key = pElement->getIntKey();
    BaseMove* move = (BaseMove*)pElement->getObject();
	this->removeChild(move,true);
}
Beispiel #18
0
DBData::~DBData()
{
    CCDictElement* pElement = NULL;
    CCDICT_FOREACH(m_dic, pElement)
    {
        CCObject* pObj = pElement->getObject();
        if (pObj)
        {
            pObj->release();
        }
    }
Beispiel #19
0
void SportLayer::hideAllPanels()
{
	CCAssert(m_allPanelNames != NULL , "m_allPanelNames is not init!");
	Layout* lay = NULL;
	CCDictElement* elm = NULL;
	CCDICT_FOREACH(m_allPanelNames , elm){
		lay = dynamic_cast<Layout*>(m_pUILayer->getWidgetByName(((CCString* )elm->getObject())->getCString() ));
		if(! lay) continue;
		lay->setVisible(false);
		lay->setTouchEnable(false,true);
	}
Beispiel #20
0
void XCCBReader::pause()
{
	CCBAnimationManager* mActionManager = getAnimationManager();
	mActionManager->getRootNode()->pauseSchedulerAndActions();

	CCDictionary* pDic = mActionManager->getNodeSequences();
	CCDictElement* pElement = NULL;
	CCDICT_FOREACH(pDic, pElement)
	{
		CCNode *node = (CCNode*)pElement->getIntKey();
		node->pauseSchedulerAndActions();
	}
//
// load file
//
void CCConfiguration::loadConfigFile( const char *filename )
{
	CCDictionary *dict = CCDictionary::createWithContentsOfFile(filename);
	CCAssert(dict, "cannot create dictionary");

	// search for metadata
	bool metadata_ok = false;
	CCObject *metadata = dict->objectForKey("metadata");
	if( metadata && dynamic_cast<CCDictionary*>(metadata) ) {
		CCObject *format_o = static_cast<CCDictionary*>(metadata)->objectForKey("format");

		// XXX: cocos2d-x returns CCStrings when importing from .plist. This bug will be addressed in cocos2d-x v3.x
		if( format_o && dynamic_cast<CCString*>(format_o) ) {
			int format = static_cast<CCString*>(format_o)->intValue();

			// Support format: 1
			if( format == 1 ) {
				metadata_ok = true;
			}
		}
		// XXX: cocos2d-x returns CCStrings when importing from .plist. This bug will be addressed in cocos2d-x v3.x
		if( format_o && dynamic_cast<CCInteger*>(format_o) ) {
			int format = dynamic_cast<CCInteger*>(format_o)->getValue();

			// Support format: 1
			if( format == 1 ) {
				metadata_ok = true;
			}
		}
	}

	if( ! metadata_ok ) {
		CCLOG("Invalid config format for file: %s", filename);
		return;
	}

	CCObject *data = dict->objectForKey("data");
	if( !data || !dynamic_cast<CCDictionary*>(data) ) {
		CCLOG("Expected 'data' dict, but not found. Config file: %s", filename);
		return;
	}

	// Add all keys in the existing dictionary
	CCDictionary *data_dict = static_cast<CCDictionary*>(data);
    CCDictElement* element;
    CCDICT_FOREACH(data_dict, element)
    {
		if( ! m_pValueDict->objectForKey( element->getStrKey() ) )
			m_pValueDict->setObject(element->getObject(), element->getStrKey() );
		else
			CCLOG("Key already present. Ignoring '%s'", element->getStrKey() );
    }
}
void CCAnimationCache::parseVersion1(CCDictionary* animations)
{
    CCSpriteFrameCache *frameCache = CCSpriteFrameCache::sharedSpriteFrameCache();

    CCDictElement* pElement = NULL;
    CCDICT_FOREACH(animations, pElement)
    {
        CCDictionary* animationDict = (CCDictionary*)pElement->getObject();
        CCArray* frameNames = (CCArray*)animationDict->objectForKey("frames");
        float delay = animationDict->valueForKey("delay")->floatValue();
        CCAnimation* animation = NULL;

        if ( frameNames == NULL ) 
        {
            CCLOG("cocos2d: CCAnimationCache: Animation '%s' found in dictionary without any frames - cannot add to animation cache.", pElement->getStrKey());
            continue;
        }

        CCArray* frames = CCArray::createWithCapacity(frameNames->count());
        frames->retain();

        CCObject* pObj = NULL;
        CCARRAY_FOREACH(frameNames, pObj)
        {
            const char* frameName = ((CCString*)pObj)->getCString();
            CCSpriteFrame* spriteFrame = frameCache->spriteFrameByName(frameName);

            if ( ! spriteFrame ) {
                CCLOG("cocos2d: CCAnimationCache: Animation '%s' refers to frame '%s' which is not currently in the CCSpriteFrameCache. This frame will not be added to the animation.", pElement->getStrKey(), frameName);

                continue;
            }

            CCAnimationFrame* animFrame = new CCAnimationFrame();
            animFrame->initWithSpriteFrame(spriteFrame, 1, NULL);
            frames->addObject(animFrame);
            animFrame->release();
        }

        if ( frames->count() == 0 ) {
            CCLOG("cocos2d: CCAnimationCache: None of the frames for animation '%s' were found in the CCSpriteFrameCache. Animation is not being added to the Animation Cache.", pElement->getStrKey());
            continue;
        } else if ( frames->count() != frameNames->count() ) {
            CCLOG("cocos2d: CCAnimationCache: An animation in your dictionary refers to a frame which is not in the CCSpriteFrameCache. Some or all of the frames for the animation '%s' may be missing.", pElement->getStrKey());
        }

        animation = CCAnimation::create(frames, delay, 1);

        CCAnimationCache::sharedAnimationCache()->addAnimation(animation, pElement->getStrKey());
        frames->release();
    }    
Beispiel #23
0
CCNode* CCBReader::readNodeGraphFromData(CCData *pData, CCObject *pOwner, const CCSize &parentSize)
{
    mData = pData;
    CC_SAFE_RETAIN(mData);
    mBytes = mData->getBytes();
    mCurrentByte = 0;
    mCurrentBit = 0;
    mOwner = pOwner;
    CC_SAFE_RETAIN(mOwner);

    mActionManager->setRootContainerSize(parentSize);
    mActionManager->mOwner = mOwner;  
    
    CCDictionary* animationManagers = CCDictionary::create();
    CCNode *pNodeGraph = readFileWithCleanUp(true, animationManagers);
    
    if (pNodeGraph && mActionManager->getAutoPlaySequenceId() != -1 && !jsControlled)
    {
        // Auto play animations
        mActionManager->runAnimationsForSequenceIdTweenDuration(mActionManager->getAutoPlaySequenceId(), 0);
    }
    // Assign actionManagers to userObject
    if(jsControlled) {
        mNodesWithAnimationManagers = new CCArray();
        mAnimationManagersForNodes = new CCArray();
    }
    
    CCDictElement* pElement = NULL;
    CCDICT_FOREACH(animationManagers, pElement)
    {
        CCNode* pNode = (CCNode*)pElement->getIntKey();
        CCBAnimationManager* manager = (CCBAnimationManager*)animationManagers->objectForKey((intptr_t)pNode);
		// (jason_shi): 将未命名的JSController命名为路径名
		if (manager->getDocumentControllerName().compare("") == 0)
		{
			CCString* pStr = dynamic_cast<CCString*>(pNode->getCustObject());
			if (pStr)
			{
				manager->setDocumentControllerName(pStr->getCString());
				pNode->setCustObject(nullptr);
			}
		}

        pNode->setUserObject(manager);

        if (jsControlled)
        {
            mNodesWithAnimationManagers->addObject(pNode);
            mAnimationManagersForNodes->addObject(manager);
        }
    }
//
// load file
//
void CCConfiguration::loadConfigFile( const char *filename )
{
	CCDictionary *dict = CCDictionary::createWithContentsOfFile(filename);
	CCAssert(dict, "cannot create dictionary");

	// Add all keys in the existing dictionary
    CCDictElement* element;
    CCDICT_FOREACH(dict, element)
    {
		if( ! m_pDefaults->objectForKey( element->getStrKey() ) )
			m_pDefaults->setObject(element->getObject(), element->getStrKey() );
		else
			CCLOG("Key already present. Ignoring '%s'", element->getStrKey() );
    }
}
Beispiel #25
0
bool AmfUtil::isSame(cocos2d::CCObject *thisObj, cocos2d::CCObject *thatObj) {
    if (thisObj && !thatObj) return false;
    if (!thisObj && thatObj) return false;
    if (!thisObj && !thatObj) return true;

    if (dynamic_cast<CCBool *>(thisObj) && dynamic_cast<CCBool *>(thatObj)) {
        return dynamic_cast<CCBool *>(thisObj)->getValue() == dynamic_cast<CCBool *>(thatObj)->getValue();
    } else if (dynamic_cast<CCInteger *>(thisObj) && dynamic_cast<CCInteger *>(thatObj)) {
        return dynamic_cast<CCInteger *>(thisObj)->getValue() == dynamic_cast<CCInteger *>(thatObj)->getValue();
    } else if (dynamic_cast<CCFloat *>(thisObj) && dynamic_cast<CCFloat *>(thatObj)) {
        return dynamic_cast<CCFloat *>(thisObj)->getValue() == dynamic_cast<CCFloat *>(thatObj)->getValue();
    } else if (dynamic_cast<CCDouble *>(thisObj) && dynamic_cast<CCDouble *>(thatObj)) {
        return dynamic_cast<CCDouble *>(thisObj)->getValue() == dynamic_cast<CCDouble *>(thatObj)->getValue();
    } else if (dynamic_cast<CCString *>(thisObj) && dynamic_cast<CCString *>(thatObj)) {
        return strcmp(dynamic_cast<CCString *>(thisObj)->getCString(), dynamic_cast<CCString *>(thatObj)->getCString()) == 0;
    } else if (dynamic_cast<CCDate *>(thisObj) && dynamic_cast<CCDate *>(thatObj)) {
        return dynamic_cast<CCDate *>(thisObj)->isEqual(dynamic_cast<CCDate *>(thatObj));
    } else if (dynamic_cast<AmfTraitsInfo *>(thisObj) && dynamic_cast<AmfTraitsInfo *>(thatObj)) {
        return dynamic_cast<AmfTraitsInfo *>(thisObj)->isEqual(dynamic_cast<AmfTraitsInfo *>(thatObj));
    } else if (dynamic_cast<AmfObject *>(thisObj) && dynamic_cast<AmfObject *>(thatObj)) {
        return dynamic_cast<AmfObject *>(thisObj)->isEqual(dynamic_cast<AmfObject *>(thatObj));
    } else if (dynamic_cast<AmfCoding *>(thisObj) && dynamic_cast<AmfCoding *>(thatObj)) {
        return dynamic_cast<AmfCoding *>(thisObj)->isEquals(thatObj);
    } else if (dynamic_cast<CCArray *>(thisObj) && dynamic_cast<CCArray *>(thatObj)) {
        CCArray *thisArray = dynamic_cast<CCArray *>(thisObj);
        CCArray *thatArray = dynamic_cast<CCArray *>(thatObj);
        int count = thisArray->count();
        int capacity = thisArray->capacity();
        if (count != thatArray->count() || (count == 0 && capacity != thatArray->capacity()))
            return false;
        for (int i = 0; i < count; i++) {
            if (!isSame(thisArray->objectAtIndex(i), thatArray->objectAtIndex(i)))
                return false;
        }
        return true;
    } else if (dynamic_cast<CCDictionary *>(thisObj) && dynamic_cast<CCDictionary *>(thatObj)) {
        CCDictionary *thisDict = dynamic_cast<CCDictionary *>(thisObj);
        CCDictionary *thatDict = dynamic_cast<CCDictionary *>(thatObj);
        int count = thisDict->count();
        if (count != thatDict->count())
            return false;
        CCDictElement *thisElement;
        CCDICT_FOREACH(thisDict, thisElement) {
                char const *thisKey = thisElement->getStrKey();
                CCObject *thatValue = thatDict->objectForKey(thisKey);
                if (!thatValue) return false;
                if (!isSame(thisElement->getObject(), thatValue)) return false;
            }
Beispiel #26
0
void CCControlButton::setPreferredSize(CCSize size)
{
    if(size.width == 0 && size.height == 0)
    {
        m_doesAdjustBackgroundImage = true;
    }
    else
    {
        m_doesAdjustBackgroundImage = false;
        CCDictElement * item = NULL;
        CCDICT_FOREACH(m_backgroundSpriteDispatchTable, item)
        {
            CCScale9Sprite* sprite = (CCScale9Sprite*)item->getObject();
            sprite->setPreferredSize(size);
        }
    }
Beispiel #27
0
void TestColliderDetector::update(float delta)
{
    armature2->setVisible(true);

    CCRect rect = bullet->boundingBox();

    // This code is just telling how to get the vertex.
    // For a more accurate collider detection, you need to implemente yourself.
    CCDictElement *element = NULL;
    CCDictionary *dict = armature2->getBoneDic();
    CCDICT_FOREACH(dict, element)
    {
        CCBone *bone = static_cast<CCBone*>(element->getObject());
        CCArray *bodyList = bone->getColliderBodyList();

        CCObject *object = NULL;
        CCARRAY_FOREACH(bodyList, object)
        {
            ColliderBody *body = static_cast<ColliderBody*>(object);
            CCArray *vertexList = body->getCalculatedVertexList();

            float minx, miny, maxx, maxy = 0;
            int length = vertexList->count();
            for (int i = 0; i<length; i++)
            {
                CCContourVertex2 *vertex = static_cast<CCContourVertex2*>(vertexList->objectAtIndex(i));
                if (i == 0)
                {
                  minx = maxx = vertex->x;
                  miny = maxy = vertex->y;
                }
                else
                {
                    minx = vertex->x < minx ? vertex->x : minx;
                    miny = vertex->y < miny ? vertex->y : miny;
                    maxx = vertex->x > maxx ? vertex->x : maxx;
                    maxy = vertex->y > maxy ? vertex->y : maxy;
                }
            }
            CCRect temp = CCRectMake(minx, miny, maxx - minx, maxy - miny);

            if (temp.intersectsRect(rect))
            {
                armature2->setVisible(false);
            }
        }
void ArmatureDataManager::removeUnusedAnimations(){
    if( m_pArmatureFileInfoDic ){
        CCTextureCache * tc = CCTextureCache::sharedTextureCache();
        CCSpriteFrameCache * sfc = CCSpriteFrameCache::sharedSpriteFrameCache();
        std::vector<std::string> cleanlist;
        CCDictElement* pElement = NULL;
        CCDICT_FOREACH(m_pArmatureFileInfoDic, pElement){
            const std::string file = pElement->getStrKey();
            ArmatureFileInfo * _fileInfo = (ArmatureFileInfo*)pElement->getObject();
            if (_fileInfo && _fileInfo->retainCount() == 1) {
                
                //清理 m_pAnimationDatas、m_pArmarureDatas、m_pTextureDatas 信息
                if( m_pAnimationDatas ){
                    m_pAnimationDatas->removeObjectForKey(_fileInfo->configFilePath);
                }
                
                if( m_pArmarureDatas ){
                    m_pArmarureDatas->removeObjectForKey(_fileInfo->configFilePath);
                }
                
                if( m_pTextureDatas ){
                    m_pTextureDatas->removeObjectForKey(_fileInfo->configFilePath);
                }
                
                //清理精灵帧、纹理和标记需要清理的ArmatureFile
                for (std::vector<ImageInfo>::iterator it = _fileInfo->imageInfoVector.begin();
                     it != _fileInfo->imageInfoVector.end();
                     it++){
                    const std::string & plist = it->plistPath;
                    const std::string & texture = it->imagePath;
                    sfc->removeSpriteFramesFromFile(plist.c_str());
                    tc->removeTextureForKey(texture.c_str());
                    cleanlist.push_back(file);
                }
            }
        }
        
        
        
        int size = cleanlist.size();
        for(int i = 0; i < size; i++) {
            m_pArmatureFileInfoDic->removeObjectForKey(cleanlist[i]);
        }
        cleanlist.clear();
    }
}
Beispiel #29
0
CCArray* ItemStatusView::getTypeArray(int type){
    int city_lv = FunBuildController::getInstance()->getMainCityLv();
    auto goodDic = LocalController::shared()->DBXMLManager()->getGroupByKey("goods");
    CCArray* array = CCArray::create();// new CCArray();
   // array->init();
    int num = 0;
    if(goodDic)
    {
        CCDictElement* element;
        CCDICT_FOREACH(goodDic, element)
        {
            CCDictionary* dictInfo = _dict(element->getObject());
            if(type==dictInfo->valueForKey("type2")->intValue() && dictInfo->valueForKey("type")->intValue()==4 && city_lv>=dictInfo->valueForKey("lv")->intValue()){
                array->addObject(dictInfo);
            }
        }
    }
void ArmatureDataManager::addSpriteFrameFromFile(const char *_plistPath, const char *_imagePath){
    //TODO:需要测试
#if USING_COCOS2D_2_1_PLUS
    std::string pszPath = CCFileUtils::sharedFileUtils()->fullPathForFilename(_plistPath);
#else
    std::string pszPath = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(_plistPath);
#endif
    
    CCDictionary *dict = CCDictionary::createWithContentsOfFileThreadSafe(pszPath.c_str());
    CCDictionary *framesDict = (CCDictionary*)dict->objectForKey("frames");
    CCDictElement* pElement = NULL;
    CCDICT_FOREACH(framesDict, pElement){
        const std::string spriteFrameName = pElement->getStrKey();
        m_Display2ImageMap[spriteFrameName] = _imagePath;
    }
    CC_SAFE_RELEASE_NULL(dict);
    CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile(_plistPath, _imagePath);
}