Cocos Creator 入门
来源:互联网
Cocos Createor
资源
略
场景
节点树
节点与组件
坐标系
脚本
组件声明,生命周期回调
var Component = cc.Class({
// 用于序列化,可省略
name: 'some Name',
// 构造函数
cotr: function() {
// 不会覆盖父类的构造函数,自动调用父类构造方法
cc.log(this instanceof Component);
},
// 继承
extends: cc.Component,
// 属性声明,可在编辑器<属性检查其>中可视化编辑。需声明类型
properties: {
id: 20, // value
target: cc.Node, // constructor
pos: new cc.Vec2(10, 20), // obj
frames: [cc.SpriteFrame], // array
// 完整声明
score: {
default: 0,
displayName: "<属性检查器>标签名",
tooltip: "<属性检查器>提示",
visible: true,
serializable: true, // false不可序列化(保存)
type: cc.Label,
}
},
// LIFE-CYCLE CALLBACKS:
onLoad: function() {
cc.log("All nodes loaded..");
},
start: function() {
cc.log("All component loaded.");
},
update: function() {
cc.log("request frame.");
},
lateUpdate: function() {
cc.log("After frame update.");
},
onDestory: function() {
cc.log("will be destoried.");
},
onEnable: function() {
cc.log("activate");
},
onDisable: function() {
cc.log("disabled.");
},
});
节点访问
Cocos Createor
资源
略
场景
节点树
节点与组件
坐标系
脚本
组件声明,生命周期回