自己vscode的快捷短语

{
/*
     // Place your snippets for Lua here. Each snippet is defined under a snippet name and has a prefix, body and 
     // description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
     // $1, $2 for tab stops, ${id} and ${id:label} and ${1:label} for variables. Variables with the same id are connected.
     // Example:
     "Print to console": {
        "prefix": "log",
        "body": [
            "console.log('$1');",
            "$2"
        ],
        "description": "Log output to console"
    }
*/

    "g_systemtip_id": {
        "prefix": "g_sys",
        "body": [
            "g_systemtip_id(1269)"
        ],
        "description": "文字库"
    },

    "g_openDlgWithName": {
        "prefix": "g_open",
        "body": [
            "g_openDlgWithName(\"UIHouseholdNew\")"
        ],
        "description": "打开窗口"
    },

    "releaseAllDlg": {
        "prefix": "g_rAllDlg",
        "body": [
            "g_dlgManager:releaseAllDlg()"
        ],
        "description": "关闭所有窗口"
    },

    "deleteDlgByName": {
        "prefix": "g_delDlg",
        "body": [
            "g_dlgManager:deleteDlgByName(\"UISpecialBag\")"
        ],
        "description": "通过窗口名关闭指定窗口"
    },

    "print ======= ": {
        "prefix": "pri=",
        "body": [
            "print(\"===================================\")"
        ],
        "description": "打印隔断符"
    },

    "g_OpenDialog": {
        "prefix": "g_OpenDialog",
        "body": [
            "local function ok()",
            "\tNetMsg_GuildStation.takeItem(sender.goodsId)",
            "end",
            "local function cancel()",
            "end",
            "local str = g_getSysStr(1753)",
            "g_OpenDialog(\"\", str, { messageFontSize = 20 }, ok, cancel)"
        ],
        "description": "打开确认取消窗口"
    },

    "-- ===": {
        "prefix": "p=",
        "body": [
            "-- ================================================="
        ],
        "description": "打印注释分隔符"
    },

    "os.execute(\"pause\")": {
        "prefix": "pzt",
        "body": [
            "os.execute(\"pause\")"
        ],
        "description": "打印暂停"
    },

    "dump": {
        "prefix": "dump",
        "body": [
            "dump(tbBigList, \"tbBigList = \")"
        ],
        "description": "dump模板"
    },

    "print": {
        "prefix": "prin",
        "body": [
            "print(\"tbBigList = \" .. tbBigList)"
        ],
        "description": "print模板"
    },

    "g_MapLayerMgr": {
        "prefix": "g_MapLayerMgr",
        "body": [
            "g_MapLayerMgr"
        ],
        "description": "g_MapLayerMgr全部变量 仅限地编"
    },

    "setContentSize": {
        "prefix": "setCon",
        "body": [
            "setContentSize(cc.size(100, 100))"
        ],
        "description": "setContentSize 设置控件大小"
    },
    
    "getContentSize": {
        "prefix": "getCon",
        "body": [
            "getContentSize() -- 返回size"
        ],
        "description": "getContentSize 得到控件大小"
    },
    
    "loadTexture全部路径": {
        "prefix": "loadTex0",
        "body": [
            "loadTexture(\"res/icon/skill_icon/\" .. nIcoId .. \".png\", ccui.TextureResType.localType)"
        ],
        "description": "loadTexture 全部路径图片"
    },

    "loadTexture缓存路径": {
        "prefix": "loadTex1",
        "body": [
            "loadTexture(\"ui_skill_11.png\", ccui.TextureResType.plistType)"
        ],
        "description": "loadTexture 缓存路径图片"
    },

    "setPercent": {
        "prefix": "setPjdt",
        "body": [
            "setPercent((nexp / upexp)*100) --nexp当前值 upexp最大值 参数 1 ~ 100之间"
        ],
        "description": "setPercent设置进度条百分比"
    },

    "setAnchorPoint": {
        "prefix": "setAmd",
        "body": [
            "setAnchorPoint(0.5, 0.5)"
        ],
        "description": "setAnchorPoint设置锚点"
    },

    "setPosition": {
        "prefix": "setPo",
        "body": [
            "setPosition(0, 0)"
        ],
        "description": "setPosition设置坐标"
    },

    "setString": {
        "prefix": "setSt",
        "body": [
            "setString(skillLv)"
        ],
        "description": "setString设置字符串"
    },

    "setText": {
        "prefix": "setTe",
        "body": [
            "setText(skillLv)"
        ],
        "description": "设置editbox字符串"
    },

    "addTouchEventListenerWithType": {
        "prefix": "tou",
        "body": [
            "local function callback(sender)",
            "\tself:setUpSelSkiInfo(sender.grougId)",
            "end",
            "self:addTouchEventListenerWithType(item, callback)"
        ],
        "description": "self添加点击响应"
    },

    "addTouchEventListener": {
        "prefix": "addTou",
        "body": [
            "local function callback(sender, eventType)",
                "\t--local name = sender:getName()",
                "\t--local tag = sender:getTag()",
                "\tif eventType == ccui.TouchEventType.began then",

                "\telseif eventType == ccui.TouchEventType.ended then",

                "\tend",
            "end",
            "item:addTouchEventListener(callback)",
        ],
        "description": "item添加点击响应"
    },

    "error": {
        "prefix": "error",
        "body": [
            "error(\"123123\")"
        ],
        "description": "error抛出一个错误 并打印堆栈"
    },

    "dispatchEvent": {
        "prefix": "disp",
        "body": [
            "cc(self):addComponent(\"components.behavior.EventProtocol\"):exportMethods()",
            "local function callback(event)",
            "\tdump(event, \"event\")",
            "end",
            "self:addEventListener(\"HEHE\", callback)",
            "self:dispatchEvent({name = \"HEHE\", x = 5, y = 10, touchInTarget = true})"
        ],
        "description": "注册一个通知消息 并通知"
    },

    "plistType": {
        "prefix": "plist",
        "body": [
            "ccui.TextureResType.plistType --localType"
        ],
        "description": "loadTexture Plist 类型"
    },

    
    "convertToWorldSpace": {
        "prefix": "tow",
        "body": [
            "convertToWorldSpace"
        ],
        "description": "节点坐标转为世界坐标"
    },

    "convertToNodeSpace": {
        "prefix": "ton",
        "body": [
            "convertToNodeSpace"
        ],
        "description": "世界坐标转换为节点坐标"
    },

    "removeAllItems": {
        "prefix": "removeAllI",
        "body": [
            "removeAllItems()"
        ],
        "description": "list控件清空"
    },

    "itemLoadTex": {
        "prefix": "itemLoadTex",
        "body": [
            "local goodsId = v[1]",
            "local i_icon = g_tab(\"TAB_item\", goodsId, \"i_icon\")",
            "item.m_Image_GooBox:loadTexture(g_getGoodsBoxPath(goodsId), ccui.TextureResType.plistType)",
            "item.m_Image_GooIco:loadTexture(g_getIconAllPath(i_icon), ccui.TextureResType.localType)"
        ],
        "description": "物品加载背景框和物品图标"
    },

    "g_osTimeToStringEX": {
        "prefix": "g_time",
        "body": [
            "g_osTimeToStringEX(nTime)"
        ],
        "description": "项目中统一使用的时间"
    },


    "addList": {
        "prefix": "addList",
        "body": [
            "function UIAndals:updateXxxList()",
            "\tlocal function addToList(k, v)",
            "\t\tlocal item = self.m_Panel_PropsItem:clone()",
            "\t\titem:show()",
            "",
            "\t\titem.data = v",
            "\t\titem.xxid = v.xxid",
            "\t\titem.m_Button_Receive.xxid = v.xxid",
            "",
            "\t\titem.m_Image_ItemBg = g_seekWidgetByName(item,\"m_Image_ItemBg\")",
            "\t\titem.m_Image_Item = g_seekWidgetByName(item,\"m_Image_Item\")",
            "\t\titem.m_Label_Num = g_seekWidgetByName(item,\"m_Label_Num\")",
            "\t\titem.m_Label_Name = g_seekWidgetByName(item,\"m_Label_Name\")",
            "\t\titem.m_Button_Receive = g_seekWidgetByName(item,\"m_Button_Receive\")",
            "",
            "\t\tlocal function callback(sender, eventType)",
            "\t\t\t--local name = sender:getName()",
            "\t\t\t--local tag = sender:getTag()",
            "\t\t\tif eventType == ccui.TouchEventType.began then",
            "\t\t\telseif eventType == ccui.TouchEventType.ended then",
            "\t\t\t\tprint(\"点击的是 \" .. sender.xxid)",
            "\t\t\tend",
            "\t\tend",
            "\t\titem.m_Button_Receive:addTouchEventListener(callback)",
            "",
            "\t\tg_insertItemInListView(self.m_ListView_Props, item)",
            "\tend",
            "",
            "\tlocal tbData = {}",
            "\tself.m_ListView_Props:removeAllItems()",
            "\tfor k, v in ipairs(tbData) do",
            "\t\taddToList(k, v)",
            "\tend",
            "end"
        ],
        "description": "一键添加listView"
    },

    "addTable": {
        "prefix": "addTable",
        "body": [
            "function UIForceMember:createHhTable()",
            "\t",
            "\tif self.tableView then",
            "\t\tself.tableView:removeFromParent()        ",
            "\tend",
            "",
            "\tcclog(\"UIForceMember:createHhTable-----------------------\"..#self.tbHh)",
            "\tlocal function setCall(cell,idx)        ",
            "\t\tself:setHhInfo(cell,self.tbHh[idx+1])",
            "\tend",
            "",
            "\tself.tableView = g_addTableView(self.m_Panel_TableViewClan,self.m_Panel_ClanItem,#self.tbHh,setCall)",
            "end",
            "",
            "function UIForceMember:setHhInfo(cell,data) ",
            "\tlocal item = cell.item",
            "\tif not data then",
            "\t\titem:hide()",
            "\t\treturn",
            "\tend",
            "",
            "\tlocal tbBanner = data.banner",
            "\tlocal szHhName = data.name",
            "\tlocal szBossName = data.masterName",
            "",
            "\titem:show()",
            "\tlocal m_Image_HhFlag = g_seekWidgetByName(item, \"m_Image_HhFlag\")",
            "\tlocal M_LABEL_ICONCHAR = g_seekWidgetByName(item, \"M_LABEL_ICONCHAR\")",
            "\tlocal m_Label_Hh_Name = g_seekWidgetByName(item, \"m_Label_Hh_Name\")",
            "\tlocal m_Label_BossName = g_seekWidgetByName(item, \"m_Label_BossName\")",
            "",
            "\tif #tbBanner > 0 then",
            "\t\tg_setHhIconChar(M_LABEL_ICONCHAR, szName, nForceId or g_playerAttr:getForceId() or 1, guildId)",
            "\t\tg_setHhIcon(tbBanner, cell[\"m_Image_HhFlag\"], nil, nil, nil)",
            "\tend",
            "",
            "\tm_Label_Hh_Name:setString(szHhName)",
            "\tm_Label_BossName:setString(szBossName)",
            "",
            "end"
        ],
        "description": "一键添加tableView"
    },

    "addTbPos": {
        "prefix": "addTbPos",
        "body": [
            "self.tbMedPos = {}",
            "for i = 1, 7 do",
            "\tlocal tempItem = g_seekWidgetByName(self._root,\"m_Panel_MedPos_\" .. i)",
            "\ttempItem:hide()",
            "\tlocal pos = cc.p(tempItem:getPosition())",
            "\tself.tbMedPos[i] = pos",
            "end"
        ],
        "description": "一键添加 得到一组控件的坐标添加到表"
    },

    "textFieldEvent": {
        "prefix": "tfe",
        "body": [
            "local function textFieldEvent(sender, eventType)",
            "\tlocal str = sender:getString()",
            "\tif eventType == ccui.TextFiledEventType.insert_text then",
            "\t\tprint(\"插入字符消息\", str)",
            "\telseif eventType == ccui.TextFiledEventType.delete_backward then",
            "\t\tprint(\"删除字符消息\", str)",
            "\tend",
            "end",
            "self.m_TextField_Lv:addEventListener(textFieldEvent)"
        ],
        "description": "一键添加 TextField 输入删除响应"
    },

    "scheduler": {
        "prefix": "dsq",
        "body": [
            "local scheduler = cc.Director:getInstance():getScheduler()",
            "local function scheduleCallBack()",
            "\t--do something",
            "\t--...",
            "\tif nil ~= schedulEntry then",
            "\t\tscheduler:unscheduleScriptEntry(schedulEntry)",
            "\tend",
            "end",
            "if nil ~= schedulEntry then",
            "\tscheduler:unscheduleScriptEntry(schedulEntry)",
            "end",
            "schedulEntry = scheduler:scheduleScriptFunc(scheduleCallBack, 0.5, false)"
        ],
        "description": "一键添加 定时器"
    },

    "listener": {
        "prefix": "onebyone",
        "body": [
            "local function onTouchBegan(touch, event)",
            "\treturn true--这里不返回true 后面不返回true",
            "end",
            "local function onTouchMoved(touch, event)",
            "\tlocal dx = touch:getDelta().x",
            "end",
            "local function onTouchEnded(touch, event)",
            "\tlocal location = touch:getLocation()",
            "end",
            "local listener = cc.EventListenerTouchOneByOne:create()",
            "listener:registerScriptHandler(onTouchBegan,cc.Handler.EVENT_TOUCH_BEGAN )",
            "listener:registerScriptHandler(onTouchMoved,cc.Handler.EVENT_TOUCH_MOVED )",
            "listener:registerScriptHandler(onTouchEnded,cc.Handler.EVENT_TOUCH_ENDED )",
            "local eventDispatcher = layer:getEventDispatcher()",
            "eventDispatcher:addEventListenerWithSceneGraphPriority(listener, layer)"
        ],
        "description": "一键添加 点击事件能获取具体坐标"
    },


}
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 204,293评论 6 478
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 85,604评论 2 381
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 150,958评论 0 337
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,729评论 1 277
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,719评论 5 366
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,630评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 38,000评论 3 397
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,665评论 0 258
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,909评论 1 299
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,646评论 2 321
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,726评论 1 330
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,400评论 4 321
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,986评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,959评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,197评论 1 260
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 44,996评论 2 349
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,481评论 2 342

推荐阅读更多精彩内容