Example #1
0
/*
 *  析构函数
 */
LoginLayer::~LoginLayer() {
    CCTextureCache* pTextureCache = CCTextureCache::sharedTextureCache();
    
    pTextureCache->removeTextureForKey("GAME_NAME.png");
    pTextureCache->removeTextureForKey("bg_big.png");
    pTextureCache->removeTextureForKey("pre.png");
    pTextureCache->removeTextureForKey("def.png");
    pTextureCache->removeTextureForKey("start.png");
    pTextureCache->removeTextureForKey("LG_nor.png");
    pTextureCache->removeTextureForKey("LG_sel.png");
}
Example #2
0
void* LoadingLayer::updateInfo(void* args)
{

    // 开线程加载plist文件,将plist加载到CCSpriteFrameCache
    CCSpriteFrameCache *cache = CCSpriteFrameCache::sharedSpriteFrameCache();
    CCTextureCache* teCache = CCTextureCache::sharedTextureCache();
    for (int i=0; i<m_staticYPlist->count() * 0.5; i++)
    {
        const char* m_pngFullPath = ((CCString* )m_staticYPlist->objectAtIndex(i))->getCString();
        const char* m_plistFullPath = ((CCString* )m_staticYPlist->objectAtIndex(i + m_staticYPlist->count() * 0.5))->getCString();
//        CCLog("m_pngFullPath:%s", m_pngFullPath);
//        CCLog("m_plistFullPath:%s", m_plistFullPath);
        
        CCTexture2D* texture = teCache->textureForKey(m_pngFullPath);
        cache->addSpriteFramesWithFile(m_plistFullPath, texture);
        // 删除纹理
        teCache->removeTextureForKey(m_pngFullPath);
    }
    // 可以异步加载数据 m_target为空,就跳过
    if (m_instance->m_target)
    {
        if (m_instance->m_callFuncData)
        {
            (m_instance->m_target->*m_instance->m_callFuncData)();
        }
        
    }
    m_instance->isOver = true;
//    m_taxiBus->runAction(CCSequence::create(
//                                            CCMoveTo::create(0.7, ccp(m_moveLength, m_taxiBus->getPosition().y)),
//                                            CCCallFunc::create(m_instance, callfunc_selector(LoadingLayer::loadingSuccessful)),
//                                            NULL));

    return NULL;
}
Example #3
0
/* 释放本技能相关 ui 资源 */
void SkillItem::releaseUI() {
    CCTextureCache* pTextureCache = CCTextureCache::sharedTextureCache();
    CCSpriteFrameCache* pSpriteFrameCache = CCSpriteFrameCache::sharedSpriteFrameCache();
    
    // 获取大文件名
    
    std::string c = getC();
    std::string pvrFile = c + ".pvr.ccz";
    std::string plistFile = c + ".plist";
    
    pTextureCache->removeTextureForKey(pvrFile.c_str());
    pSpriteFrameCache->removeSpriteFramesFromFile(plistFile.c_str());
}
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();
    }
}
Example #5
0
void CCDirector::createStatsLabel()
{
    CCTexture2D *texture = NULL;
    CCTextureCache *textureCache = CCTextureCache::sharedTextureCache();

    if( m_pFPSLabel && m_pSPFLabel )
    {
        CC_SAFE_RELEASE_NULL(m_pFPSLabel);
        CC_SAFE_RELEASE_NULL(m_pSPFLabel);
        CC_SAFE_RELEASE_NULL(m_pDrawsLabel);
        textureCache->removeTextureForKey("cc_fps_images");
        CCFileUtils::sharedFileUtils()->purgeCachedEntries();
    }

    CCTexture2DPixelFormat currentFormat = CCTexture2D::defaultAlphaPixelFormat();
    CCTexture2D::setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA4444);
    unsigned char *data = NULL;
    unsigned int data_len = 0;
    getFPSImageData(&data, &data_len);

    CCImage* image = new CCImage();
    bool isOK = image->initWithImageData(data, data_len);
    if (!isOK) {
        CCLOGERROR("%s", "Fails: init fps_images");
        return;
    }

    texture = textureCache->addUIImage(image, "cc_fps_images");
    CC_SAFE_RELEASE(image);

    /*
     We want to use an image which is stored in the file named ccFPSImage.c 
     for any design resolutions and all resource resolutions. 
     
     To achieve this,
     
     Firstly, we need to ignore 'contentScaleFactor' in 'CCAtlasNode' and 'CCLabelAtlas'.
     So I added a new method called 'setIgnoreContentScaleFactor' for 'CCAtlasNode',
     this is not exposed to game developers, it's only used for displaying FPS now.
     
     Secondly, the size of this image is 480*320, to display the FPS label with correct size, 
     a factor of design resolution ratio of 480x320 is also needed.
     */
    float factor = 1.0f; // CCEGLView::sharedOpenGLView()->getDesignResolutionSize().height / 320.0f;

    m_pFPSLabel = new CCLabelAtlas();
    m_pFPSLabel->setIgnoreContentScaleFactor(true);
    m_pFPSLabel->initWithString("00.0", texture, 12, 32 , '.');
    m_pFPSLabel->setScale(factor);

    m_pSPFLabel = new CCLabelAtlas();
    m_pSPFLabel->setIgnoreContentScaleFactor(true);
    m_pSPFLabel->initWithString("0.000", texture, 12, 32, '.');
    m_pSPFLabel->setScale(factor);

    m_pDrawsLabel = new CCLabelAtlas();
    m_pDrawsLabel->setIgnoreContentScaleFactor(true);
    m_pDrawsLabel->initWithString("000", texture, 12, 32, '.');
    m_pDrawsLabel->setScale(factor);

    CCTexture2D::setDefaultAlphaPixelFormat(currentFormat);

    m_pDrawsLabel->setPosition(ccpAdd(ccp(0, 34*factor), CC_DIRECTOR_STATS_POSITION));
    m_pSPFLabel->setPosition(ccpAdd(ccp(0, 17*factor), CC_DIRECTOR_STATS_POSITION));
    m_pFPSLabel->setPosition(CC_DIRECTOR_STATS_POSITION);
}
Example #6
0
File: Demo.cpp Project: qjsy/QjGit
/*
 *  析构函数
 */
Demo::~Demo() {
    CCTextureCache* pTextureCache = CCTextureCache::sharedTextureCache();
    pTextureCache->removeTextureForKey("des.png");
    pTextureCache->removeTextureForKey("desfont.png");
}