quick-3.6源码修改纪录

1.CCSprite.cpp第158行改为

bool Sprite::initWithFile(const std::string& filename)

{
    CCASSERT(filename.size()>0, "Invalid filename for sprite");


    Texture2D *texture = Director::getInstance()->getTextureCache()->addImage(filename);
    if (texture)
    {
        Rect rect = Rect::ZERO;
        rect.size = texture->getContentSize();
        return initWithTexture(texture, rect);
    }
    else
    {
        Rect rect = Rect::ZERO;
        texture = Director::getInstance()->getTextureCache()->addImage("picnull.png");
        rect.size = texture->getContentSize();
        return initWithTexture(texture, rect);
    }
    // don't release here.
    // when load texture failed, it's better to get a "transparent" sprite then a crashed program
    // this->release();
    return false;

}


bool Sprite::initWithFile(const std::string &filename, const Rect& rect)
{
    CCASSERT(filename.size()>0, "Invalid filename");


    Texture2D *texture = Director::getInstance()->getTextureCache()->addImage(filename);
    if (texture)
    {
        return initWithTexture(texture, rect);
    }
    else
    {
        Rect rect = Rect::ZERO;
        texture = Director::getInstance()->getTextureCache()->addImage("picnull.png");
        rect.size = texture->getContentSize();
        return initWithTexture(texture, rect);
    }
    // don't release here.
    // when load texture failed, it's better to get a "transparent" sprite then a crashed program
    // this->release();
    return false;
}


2.CCLabel.cpp第903行

if (_currLabelEffect == LabelEffect::OUTLINE || _currLabelEffect == LabelEffect::GLOW)
{
    glprogram->setUniformLocationWith4f(_uniformEffectColor,
                                        _shadowColor4F.r, _shadowColor4F.g, _shadowColor4F.b, _shadowColor4F.a);
}


3.lua_cocos2dx_studio_auto.cpp 第21271行

#include "CocoStudio.h"
#include "CCLuaEngine.h"

int lua_cocos2dx_studio_ActionTimeline_setLastFrameCallFunc(lua_State* tolua_S)
{
    if (nullptr == tolua_S)
        return 0;
    
    int argc = 0;
    cocostudio::timeline::ActionTimeline* self = nullptr;
    
#if COCOS2D_DEBUG >= 1
    tolua_Error tolua_err;
    if (!tolua_isusertype(tolua_S,1,"ccs.ActionTimeline",0,&tolua_err)) goto tolua_lerror;
#endif
    
    self = static_cast<cocostudio::timeline::ActionTimeline*>(tolua_tousertype(tolua_S,1,0));
    
#if COCOS2D_DEBUG >= 1
    if (nullptr == self) {
        tolua_error(tolua_S,"invalid 'self' in function 'lua_cocos2dx_ActionTimeline_setLastFrameCallFunc'\n", NULL);
        return 0;
    }
#endif
    argc = lua_gettop(tolua_S) - 1;
    
    if (1 == argc)
    {
#if COCOS2D_DEBUG >= 1
        if (!toluafix_isfunction(tolua_S,2,"LUA_FUNCTION",0,&tolua_err) )
        {
            goto tolua_lerror;
        }
#endif
        
        LUA_FUNCTION handler = (  toluafix_ref_function(tolua_S,2,0));
        self->setLastFrameCallFunc([=](){
            LuaEngine::getInstance()->getLuaStack()->executeFunctionByHandler(handler, 0);
        });
        
        return 0;
    }
    
    
    luaL_error(tolua_S, "'setLastFrameCallFunc' function of ActionTimeline has wrong number of arguments: %d, was expecting %d\n", argc, 1);
    
#if COCOS2D_DEBUG >= 1
tolua_lerror:
    tolua_error(tolua_S,"#ferror in function 'setLastFrameCallFunc'.",&tolua_err);
#endif
    return 0;
}


doAnimationWhenKeyboardMoveWithDuration

4.cocos_libs/ platform/ios/CCEAGLView-ios.mm 862行doAnimationWhenKeyboardMoveWithDuration方法

dis = 0;


5.调用display.captureScreen出现崩溃问题,utils类替换3.8版本的


6.TextReader.cpp替换回3.5版本的


7.ActionTimeline.cpp194行step方法替换3.5版本的


8.3d模型透贴问题修改:rag

在ccShader_3D_ColorTex.frag和ccShader_3D_ColorNormalTex.frag中的main里面添加

  vec4 albedo = texture2D(CC_Texture0, TextureCoordOut);

   if(albedo.a < 1.0/255.0) discard;

9.3d模型骨骼绑定的物品会跟随旋转的问题修改:

const Mat4& AttachNode::getNodeToParentTransform() const
{
    Node::getNodeToParentTransform();
    Mat4 mat = _attachBone->getWorldMat();
    Vec3 scale, translation;
    Quaternion rot;
    mat.decompose(&scale, &rot, &translation);
    Mat4::createTranslation(translation, &mat);
    
    _transformToParent =  mat * _transform;
    return _transformToParent;
}


10.3d动作播放一半切换动作卡顿问题修改

在Animate3D.cpp的void Animate3D::startWithTarget(Node *target)第247行增加s_runningAnimates.erase(target);


11.修复anroid使用PUParticleSystem3D并且是热更新的话,会出现读取不到.material文件的bug

找到CCPUTranslateManager.cpp文件的loadMaterialsFromSearchPaths方法注释掉下面方法

//    std::string::size_type pos = fileFolder.find("assets/");
//    std::string relativePath = fileFolder;
//    if (pos != std::string::npos) {
//        // "assets/" is at the beginning of the path and we don't want it
//        relativePath = fileFolder.substr(pos + strlen("assets/"));
//    }
//    AAssetDir *dir = AAssetManager_openDir(FileUtilsAndroid::getAssetManager(), relativePath.c_str());
//    const char *fileName = nullptr;
//    std::string seg("/");
//    while ((fileName = AAssetDir_getNextFileName(dir)) != nullptr)
//    {
//        std::string fullpath = fileFolder + seg + std::string(fileName);
//        loadMaterials(fullpath);
//    }
//    AAssetDir_close(dir);

改为

 DIR *d; //dir handle
    struct dirent *file; //readdir
    struct stat statbuf;
    
    if(!(d = opendir(fileFolder.c_str())))
    {
        CCLOG("error opendir %s!!!\n",fileFolder.c_str());
        return false;
    }
    while((file = readdir(d)) != NULL)
    {
        if(strncmp(file->d_name, ".", 1) == 0 || (stat(file->d_name, &statbuf) >= 0 && S_ISDIR(statbuf.st_mode)))
        {
            continue;
        }
        
        std::string fullpath = fileFolder + "/" + file->d_name;
        if (strlen(file->d_name) > 9 && (strcmp(".material", file->d_name + strlen(file->d_name) - 9) == 0))
        {
            CCLOG("%s", fullpath.c_str());
            loadMaterials(fullpath);
            state = true;
        }
    }
    closedir(d);

并且加上头文件

#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>


12.修改CCFontAtlas文件的第37行

const int FontAtlas::CacheTextureWidth = 256;
const int FontAtlas::CacheTextureHeight = 256;


13.修改TextureCache文件316行

Texture2D * TextureCache::addImage(const std::string &path)
{
    Texture2D * texture = nullptr;
    Image* image = nullptr;
    // Split up directory and filename
    // MUTEX:
    // Needed since addImageAsync calls this method from a different thread


    std::string fullpath = FileUtils::getInstance()->fullPathForFilename(path);
    if (fullpath.size() == 0)
    {
        return nullptr;
    }
    
    Texture2D::PixelFormat curFormat = Texture2D::getDefaultAlphaPixelFormat();
    auto pos = fullpath.find_last_of(".");
    string fileFormatName = fullpath.substr(pos + 1);
    if(fileFormatName == "jpg"){
        Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGB565);
    }
    
    
    auto it = _textures.find(fullpath);
    if( it != _textures.end() )
        texture = it->second;


    if (! texture)
    {
        // all images are handled by UIImage except PVR extension that is handled by our own handler
        do 
        {
            image = new (std::nothrow) Image();
            CC_BREAK_IF(nullptr == image);


            bool bRet = image->initWithImageFile(fullpath);
            CC_BREAK_IF(!bRet);


            texture = new (std::nothrow) Texture2D();


            if( texture && texture->initWithImage(image) )
            {
#if CC_ENABLE_CACHE_TEXTURE_DATA
                // cache the texture file name
                VolatileTextureMgr::addImageTexture(texture, fullpath);
#endif
                // texture already retained, no need to re-retain it
                _textures.insert( std::make_pair(fullpath, texture) );
            }
            else
            {
                CCLOG("cocos2d: Couldn't create texture for file:%s in TextureCache", path.c_str());
            }
        } while (0);
    }
    Texture2D::setDefaultAlphaPixelFormat(curFormat);
    CC_SAFE_RELEASE(image);


    return texture;
}





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值