>>>>>
本文目的在于理解新建的默认类。
// 这里是装饰器
const {ccclass, property} = cc._decorator;
// 表示这是cocos类
@ccclass
// 表示NewClass是可导出的类 继承自 cocos组件类
export default class NewClass extends cc.Component {
// 编辑器属性装饰器 可在编辑器内展示 label 这个属性,组件类型是cc.Label
@property(cc.Label)
label: cc.Label = null;
// 编辑器属性装饰器 可在编辑器内展示 text 这个属性,组件类型是 字符串
@property
text: string = 'hello';
// 这个函数在节点激活是调用
onLoad () {}
// 在脚本组件激活是调用。
start () {
}
// 每帧刷新的函数,cocos内置。dt是距离上一次调用的时间,单位秒。
update (dt) {}
// 当前脚本函数的调用顺序:onLoad > start > update
// 详细内容会新开关于《脚本生命周期》的帖子讲解
}
这个是在CocosCreator2.x编辑器内新建的默认组件类。
目录:CocosCreator经典笔记_神兽白泽-CSDN博客
笔者qq、微信:1302109196
qq群:415468592
>>>>>