TypeScipt的用户代码片段
{
"create class":{
"prefix": "crtc",
"body": [
"/** Created by Naiking.",
" * $CURRENT_YEAR-$CURRENT_MONTH-$CURRENT_DATE $CURRENT_HOUR:$CURRENT_MINUTE:$CURRENT_SECOND",
" * ",
" */",
"//Learn TS:https://docs.cocos.com/creator/manual/zh/scripting/typescript.html",
"//Learn Attribute:https://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html",
"//Life-cycle:https://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html",
"const {ccclass, property} = cc._decorator;",
"@ccclass",
"export default class $TM_FILENAME_BASE extends cc.Component {",
"\t//@property(cc.Label)",
"\t//label: cc.Label = null;",
"\t//onLoad(){}",
"\tstart(){",
"\t\t",
"\t}",
"\tupdate(dt){}",
"}"]
},
}
提供一套较常见的“用户代码片段”
“文件”--“首选项”--“用户代码片段”--选择一个你需要设置的开发语言
本例是以javascript为例。(typesciprt的也同样的定义关键字)
其实这个文件,已经提供的一个最基础的示例了。
我的自定义添加了:创建文件块,加入作者,创建时间,设置光标,缩进符号
{
// Place your snippets for javascript 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, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
// same ids are connected.
// Example:
// "Print to console": {
// "prefix": "log",
// "body": [
// "console.log('$1');",
// "$2"
// ],
// "description": "Log output to console"
// }
"import namespace":{
"prefix": "import",
"body": "let $1=require('$1');",
"description": "import"
},
"create class":{
"prefix": "crtc",
"body": [
"/** Created by Naiking.",
" * $CURRENT_YEAR-$CURRENT_MONTH-$CURRENT_DATE $CURRENT_HOUR:$CURRENT_MINUTE:$CURRENT_SECOND",
" * ",
" */",
"var $TM_FILENAME_BASE = cc.Class({",
"// extends: cc.Component,",
"\tname: '$TM_FILENAME_BASE',",
"\tproperties: {",
"\t\t$1",
"\t},",
"\tctor: function () {",
"\t\t//this.xxx=arguments[0];",
"\t}",
"});",
"module.exports =$TM_FILENAME_BASE;"]
},
"signal instance":{
"prefix": "signal",
"body": [
"_instance:null,",
"getInstance:function(){",
"\tif(!$TM_FILENAME_BASE._instance)",
"\t{",
"\t\t$TM_FILENAME_BASE._instance=new $TM_FILENAME_BASE();",
"\t}",
"\treturn $TM_FILENAME_BASE._instance;",
"}"
]
},
"add new event type":{
"prefix": "evttype",
"body": "$1:'$1'"
}
}
更详细的请参阅:
https://blog.csdn.net/maokelong95/article/details/54379046