cocos creator基础-cocos基本组件和事件
发布时间:2020-12-14 18:55:31 所属栏目:百科 来源:网络整理
导读:1 cc.Class({ 2 extends : cc.Compoment, 3 4 properties : { 5 num : 0, // cc.Interger 6 string : ‘‘, // cc.String 7 bool : false , // cc.Boolean 8 array: [cc.Integer], 9 10 myNode : cc.Node, 11 // myComponent : cc.Component, 12 boxCollider
1 cc.Class({ 2 extends : cc.Compoment, 3 4 properties : { 5 num : 0,// cc.Interger 6 string : ‘‘,//cc.String 7 bool : false,//cc.Boolean 8 array: [cc.Integer], 9 10 myNode : cc.Node,11 //myComponent : cc.Component, 12 boxCollider : cc.BoxCollider,13 circleCollider : cc.CircleCollider,14 polygonCollider : cc.PolygonCollider,15 16 animation : cc.Animation,17 audioSource : cc.AudioSource,18 motionStreak : cc.MotionStreak,19 20 sprite : cc.Sprite,21 labe : cc.Label,22 23 custom : require(‘script-name‘),24 25 button : cc.Button,26 27 _private : 5,// 带_的是私有变量,不在面板显示 用get set方法 28 public : { 29 type : cc.Integer,30 visible : function(){ 31 return !!this._private; 32 },33 get: function(){return this._private;},34 set: function(value){this._private = value;},35 },36 complexPorp : { 37 38 },39 },40 41 onLoad : function(){ // 脚本加载时调用 42 43 },44 45 start : function(){ // 在所有文件的onLoad调用完之后调用 46 47 },48 49 onEnable : function(){ // 组件活动的时候调用 50 51 },52 53 onDisable : function(){ // 组件睡眠时候调用 54 55 },56 57 onDestroy : function(){ //组件销毁时 58 59 },60 61 update : function(dt){ // 组件正在活动时,每1/60秒调用一次update 62 63 },64 65 lateUpdate : function(dt){ // 组件正在活动时,在所有组件的update调用完成之后调用 66 67 } 68 }); 69 70 // cocos层级遮挡关系,层级管理器越靠上的越先渲染,就越容易被其他物体遮挡 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |