一些琐碎的记录:cocos2d-x,git,Mou,lua,正则

  1. cocos2d-x工程的安卓版本突然编译不过,而且和上次也没有任何代码的改动,报出

    error: undefined reference to 'cocos2d::PointArray::create(int) 
    

    之类的,有可能是上次编译的中间文件没删,同时编译环境变了 , 删除相关目录(proj.android/obj/)即可. http://discuss.cocos2d-x.org/t/solved-cocos2d-x-3-2-error-undefined-reference-to/16677.
    一样的情况,升级了ndk版本:

    my situation is different: i builded it with ndk-r10b and failed at the beginning, i find that it is a bug of ndk-r10b, so use ndk-r9d instead, but forgetting clean up the project.

    clean up, must clean up. it took me 2 days to solve it. never forget clean up.

  2. lua的正则表达式不支持分组,一个处理聊天消息的正则备份:

    --string.utable("[f:smile]窗外abc的[护送]麻[f:cry]雀")  ======> ["[f:smile]","窗","外","a","b","c","的","[","护","送","]","麻","[f:cry]","雀"]   
    
    string.utable=function(str)
        local tab={}
    
        --UTF8 and emoji POSIX regex pattern:([[f]:[^s[]]+])|([1-127194-244][128-191]*)
        --for uchar in string.gfind(str, '(%[[f]:[^%s%[%]]+%])|([1-127194-244][128-191]*)') do tab[#tab+1] = uchar end
    
        --Lua doesn't support the standard POSIX regex,so the standard beautiful pattern above can not work.  
        --So we can only use the dirty code below to complete the feature...
    
        local bracketFlag=false
        local emojiFlag=false
    
        for uchar in string.gfind(str, '[1-127194-244][128-191]*') do 
            if uchar=="[" then
                bracketFlag=true
                tab[#tab+1] = uchar 
            elseif uchar=="]" then
                bracketFlag=false
                if emojiFlag then
                    tab[#tab] = tab[#tab]..uchar 
                    emojiFlag=false
                else
                    tab[#tab+1] = uchar 
                end
            elseif bracketFlag and uchar=="f" then
                emojiFlag=true
                tab[#tab] = tab[#tab]..uchar
            else
                if emojiFlag then
                    tab[#tab] = tab[#tab]..uchar 
                else
                    tab[#tab+1] = uchar 
                end
            end
        end
    
        --dump(tab,"-----tab  ")
        return tab
    end  
    
  3. Mou快捷键:

    View  
    显示预览窗口 Toggle live preview: Shift + Cmd + I 
    显示字数 Toggle Words Counter: Shift + Cmd + W 
    将当前窗口设置为透明窗口 Toggle Transparent: Shift + Cmd + T
    固定当前窗口 Toggle Floating: Shift + Cmd + F
    编辑窗口和预览窗口相等 Left/Right = 1/1: Cmd + 0
    编辑窗口和预览窗口的显示比例为 3:1 Left/Right = 3/1: Cmd + +
    编辑窗口和预览窗口的显示比例为 1:3 Left/Right = 1/3: Cmd + -
    文字方向 Toggle Writing orientation: Cmd + L
    全屏显示开关 Toggle fullscreen: Control + Cmd + F
    Actions
    Copy HTML: Option + Cmd + C
    重点显示选中文本 Strong: Select text, Cmd + B
    将选中文本斜体显示 Emphasize:Select text, Cmd + I
    Inline Code: Select text, Cmd + K
    加删除线 Strikethrough: Select text, Cmd + U
    插入超链接 Link: Select text, Control + Shift + L
    插入图像 Image: Select text, Control + Shift + I
    选中当前单词 Select Word: Control + Option + W
    选中当前行 Select Line: Shift + Cmd + L
    选中所有 Select All: Cmd + A
    取消选中所有 Deselect All: Cmd + D
    将选中文本 转化为大写字母 Convert to Uppercase: Select text, Control + U
    将选中文本 转化为小写字母 Convert to Lowercase: Select text, Control + Shift + U
    将选中文本所有单词的首字母转为 大专栏  一些琐碎的记录:cocos2d-x,git,Mou,lua,正则大写Convert to Titlecase: Select text, Control + Option + U
    将选中文本插入编号 Convert to List: Select lines, Control + L
    将选中文本转换成引用块 Convert to Blockquote: Select lines, Control + Q
    将光标所在行转化为1级标题 Convert to H1: Cmd + 1
    将光标所在行转化为2级标题 Convert to H2: Cmd + 2
    将光标所在行转化为3级标题 Convert to H3: Cmd + 3
    将当前行转化为4级标题 Convert to H4: Cmd + 4
    将当前行转化为5级标题 Convert to H5: Cmd + 5
    将当前行转化为6级标题 Convert to H6: Cmd + 6
    Convert Spaces to Tabs: Control + [
    Convert Tabs to Spaces: Control + ]
    插入当前日期 Insert Current Date: Control + Shift + 1
    插入当前时间 Insert Current Time: Control + Shift + 2
    插入<符号 Insert entity <: Control + Shift + ,
    插入>符号 Insert entity >: Control + Shift + .
    插入$符号 Insert entity &: Control + Shift + 7
    Insert entity Space: Control + Shift + Space
    Insert Scriptogr.am Header: Control + Shift + G
    左缩进 Shift Line Left: Select lines, Cmd + [
    右缩进 Shift Line Right: Select lines, Cmd + ]
    插入下一行 New Line: Cmd + Return
    添加注释 Comment: Cmd + /
    插入换行符 Hard Linebreak: Control + Return
    Edit
    自动完成单词 Auto complete current word: Escape
    查找 voiceFind: Cmd + F
    取消查找框 Close find bar: Esc
    Post
    Post on Scriptogr.am: Control + Shift + S
    提交到 Tunblr Post on Tumblr: Control + Shift + T
    Export
    导出为HTML格式文件 Export HTML: Option + Cmd + E
    导出为PDF格式文件 Export PDF: Option + Cmd + P  
    
  4. 只需往主干合并某一些特性时,注意这些特性的提交不要和不需要提交的放入同一个commit,执行

    git cherry-pick <commit id>
    

    gitlab新建项目会自动保护master分支,需管理员账户在后台设置master的保护状态为 unprotected
    git log 的格式定制,方便脚本处理:

    git log --pretty=oneline 
    git log --pretty=format:"%cn %cr %h  %s"|grep your_name 
    

    配置.gitignore的相关目录无效,原因可能是之前已经成功提交了该目录,之后再把该目录配置在.gitignore里是无效的,需执行:

    git rm -rf folder
    

    一些情况下某些commit被删除,比如

    git reset --hard <commit id> 
    

    之后,这个commit id之后的那个commit在git log中消失,这时需要查看reference log

    git reflog
    

    就可以找到删除的commit
    分支或者提交被删除后,因为一些原因 .git/logs/ 丢失,那么git reflog将会失效 ,这时寻找悬空的对象,需执行:

    git fsck --lost-found
    获取commit hash
    git show commit hash
    

    git命令的自动补全:
    https://raw.github.com/git/git/master/contrib/completion/git-completion.bash

    配置 ~/.bash_profile:

    if [ -f ~/.git-completion.bash ]; then
        . ~/.git-completion.bash
    fi  
    
  5. 新版cocos2d-x如果设置了多层节点,每层都有较复杂的opengl操作, 移动 缩放 逐像素渲染(片段着色器) 等操作 , 有可能会花屏 错乱 , 旧版cocos2d-x不存在该问题 , 原因是新版cocos2d-x的工程默认兼容3D同时做得不完善, 关闭一些设置后即可解决:

    Director::getInstance()->setDepthTest(false);
    

    解决了闪屏问题但是层与层之间的关系在安卓手机上有错乱.所以使用下面的设置:

    Director::getInstance()->setProjection(Director::Projection::_3D);
    

    改为:

    Director::getInstance()->setProjection(Director::Projection::_2D);
    

猜你喜欢

转载自www.cnblogs.com/wangziqiang123/p/11710835.html