{
/*
// 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": "一键添加 点击事件能获取具体坐标"
},
}
自己vscode的快捷短语
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...