/****************************************************************** * Copyright(C) 2019 - 2020 Nx Studio * * 埋点组件:点击 * * 2018.05.18 ******************************************************************/ const TDefine = require( "trace.define" ); cc.Class({ extends: cc.Component, properties: { idType: { default: 0, type: TDefine.TraceType, displayName: "埋点类型" }, btnName: { default: "", displayName: "按钮名" }, }, // 编辑器特性 editor: { // 允许当前组件在编辑器模式下运行 executeInEditMode: false, // requireComponent 参数用来指定当前组件的依赖组件 requireComponent: cc.Button, // 当本组件添加到节点上后,禁止同类型(含子类)的组件再添加到同一个节点,防止逻辑发生冲突 disallowMultiple: true, // menu 用来将当前组件添加到组件菜单中,方便用户查找 menu: "Nx/埋点|按钮点击", }, // 显示 onEnable: function() { this.node.on( "click", this.onCatchClicked, this ); }, // 隐藏 onDisable: function() { this.node.off( "click", this.onCatchClicked, this ); }, // 点击 onCatchClicked: function() { if( !nx.mTrace || !nx.dt.numPositive( this.idType, false ) || nx.dt.strEmpty( this.btnName ) ) { return; } nx.mTrace.trace( this.idType, this.btnName ); }, });