mirror of
https://github.com/szrpf/DataBoardDemo.git
synced 2025-11-03 12:55:40 +00:00
v2.3
This commit is contained in:
@@ -63,7 +63,7 @@ var DataBoard = /** @class */ (function (_super) {
|
||||
_this._collideBoxColor = new cc.Color(Math.random() * 255, Math.random() * 255, Math.random() * 255);
|
||||
_this._collideBoxOpacity = 100;
|
||||
_this._isCustomLabelActive = true;
|
||||
_this.customComponentName = '';
|
||||
_this._customComponentName = '';
|
||||
_this._customLabelString = 'x,y';
|
||||
_this._customLabelOffset = cc.v2(0, 100);
|
||||
_this._customLabelColor = new cc.Color(255, 255, 0);
|
||||
@@ -149,12 +149,23 @@ var DataBoard = /** @class */ (function (_super) {
|
||||
configurable: true
|
||||
});
|
||||
;
|
||||
Object.defineProperty(DataBoard.prototype, "customComponentName", {
|
||||
get: function () { return this._customComponentName; },
|
||||
set: function (value) {
|
||||
this._customComponentName = value;
|
||||
value || (value = this.node.name);
|
||||
value && (this.monitorComp = this.node.getComponent(value));
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
;
|
||||
Object.defineProperty(DataBoard.prototype, "customLabelString", {
|
||||
get: function () { return this._customLabelString; },
|
||||
set: function (value) {
|
||||
this._customLabelString = value;
|
||||
this.customLabelStringSplit = value
|
||||
.replace(/,|,/g, '_~_').replace(/:|:/g, '_!_').replace(/ /g, '_@_')
|
||||
.replace(/,/g, '_~_').replace(/:/g, '_!_').replace(/ /g, '_@_')
|
||||
.replace(/_*\n_*/g, '_\n_').split('_');
|
||||
},
|
||||
enumerable: false,
|
||||
@@ -204,20 +215,19 @@ var DataBoard = /** @class */ (function (_super) {
|
||||
});
|
||||
;
|
||||
DataBoard.prototype.start = function () {
|
||||
this.boardNode = this.node.getChildByName('DataBoard');
|
||||
if (!CC_EDITOR && !window['DATABOARD']) {
|
||||
this.destroy();
|
||||
return;
|
||||
}
|
||||
this.boardNode = this.node.getChildByName('DataBoard');
|
||||
if (cc.isValid(this.boardNode)) {
|
||||
this.boardNode.removeFromParent();
|
||||
this.boardNode.destroy();
|
||||
this.boardNode.removeFromParent();
|
||||
}
|
||||
var texture = new cc.Texture2D();
|
||||
texture.initWithData(new Uint8Array([255, 255, 255]), cc.Texture2D.PixelFormat.RGB888, 1, 1);
|
||||
this.boardNode = new cc.Node('DataBoard');
|
||||
this.boardNode.setParent(this.node);
|
||||
this.boardNode.x = this.boardNode.y = 0;
|
||||
this.boardNode.zIndex = cc.macro.MAX_ZINDEX;
|
||||
this.boardNode['_objFlags'] |= cc.Object['Flags'].HideInHierarchy;
|
||||
this.boardNode['_objFlags'] |= cc.Object['Flags'].LockedInEditor;
|
||||
@@ -249,6 +259,7 @@ var DataBoard = /** @class */ (function (_super) {
|
||||
this.customLabelNode.y = this.customLabelOffset.y;
|
||||
this.customLabelNode.color = this.customLabelColor;
|
||||
this.customLabelSize = this._customLabelSize;
|
||||
this.customComponentName = this._customComponentName;
|
||||
this.updateAngle();
|
||||
this.updateScale();
|
||||
this.updateAnchor();
|
||||
@@ -287,18 +298,8 @@ var DataBoard = /** @class */ (function (_super) {
|
||||
return;
|
||||
if (!this.customLabelStringSplit)
|
||||
return;
|
||||
if (this.customLabelOffset.x !== 0 || this.customLabelOffset.y !== 0) {
|
||||
var radian = -this.node.angle * Math.PI / 180;
|
||||
var cos = Math.cos(radian);
|
||||
var sin = Math.sin(radian);
|
||||
this.customLabelNode.x = this.customLabelOffset.x * cos - this.customLabelOffset.y * sin;
|
||||
this.customLabelNode.y = this.customLabelOffset.x * sin + this.customLabelOffset.y * cos;
|
||||
}
|
||||
var str = '';
|
||||
var strs = this.customLabelStringSplit;
|
||||
if (!this.monitorComp && this.customComponentName) {
|
||||
this.monitorComp = this.node.getComponent(this.customComponentName);
|
||||
}
|
||||
var str = '';
|
||||
for (var i = 0, len = strs.length; i < len; ++i) {
|
||||
var tmp = null;
|
||||
switch (strs[i]) {
|
||||
@@ -317,7 +318,7 @@ var DataBoard = /** @class */ (function (_super) {
|
||||
tmp = '';
|
||||
for (var i_1 = 0; i_1 < 4; ++i_1) {
|
||||
for (var j = 0; j < 4; ++j) {
|
||||
var m = matrix[j * 4 + i_1];
|
||||
var m = matrix[(j << 2) + i_1];
|
||||
tmp += (m < 0 ? '\t\t' : '\t\t\t') + m.toFixed(this.customLabelDigit);
|
||||
}
|
||||
i_1 !== 3 && (tmp += '\n');
|
||||
@@ -362,12 +363,12 @@ var DataBoard = /** @class */ (function (_super) {
|
||||
this.customLabel.string = str;
|
||||
};
|
||||
DataBoard.prototype.parseString = function (str) {
|
||||
var _a, _b;
|
||||
var strs = str.split('.');
|
||||
var ret = this.monitorComp[strs[0]];
|
||||
ret === undefined && (ret = "#" + strs[0]);
|
||||
var ret = (_a = this.monitorComp[strs[0]]) !== null && _a !== void 0 ? _a : "#" + strs[0];
|
||||
for (var i = 1, len = strs.length; i < len; ++i) {
|
||||
if (ret[strs[i]] === undefined) {
|
||||
return (ret.name ? ret.name : ret) + "." + strs[i];
|
||||
return ((_b = ret.name) !== null && _b !== void 0 ? _b : ret) + "." + strs[i];
|
||||
}
|
||||
ret = ret[strs[i]];
|
||||
}
|
||||
@@ -375,8 +376,8 @@ var DataBoard = /** @class */ (function (_super) {
|
||||
};
|
||||
DataBoard.prototype.onDestroy = function () {
|
||||
if (cc.isValid(this.boardNode)) {
|
||||
this.boardNode.removeFromParent();
|
||||
this.boardNode.destroy();
|
||||
this.boardNode.removeFromParent();
|
||||
}
|
||||
this.node.targetOff(this);
|
||||
};
|
||||
@@ -422,9 +423,12 @@ var DataBoard = /** @class */ (function (_super) {
|
||||
__decorate([
|
||||
property({ displayName: CC_DEV && '自定义参数', tooltip: CC_DEV && '配置显示的属性内容' })
|
||||
], DataBoard.prototype, "isCustomLabelActive", null);
|
||||
__decorate([
|
||||
property
|
||||
], DataBoard.prototype, "_customComponentName", void 0);
|
||||
__decorate([
|
||||
property({ displayName: CC_DEV && '······脚本', tooltip: CC_DEV && '监控哪个脚本', visible: function () { return this.isCustomLabelActive; } })
|
||||
], DataBoard.prototype, "customComponentName", void 0);
|
||||
], DataBoard.prototype, "customComponentName", null);
|
||||
__decorate([
|
||||
property
|
||||
], DataBoard.prototype, "_customLabelString", void 0);
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -599,7 +599,7 @@
|
||||
"_is3DNode": false,
|
||||
"_groupIndex": 0,
|
||||
"groupIndex": 0,
|
||||
"_id": "3d8RDqQvVEfJkF7nWvrxTE"
|
||||
"_id": "76KDntjjFLVKmtFHxYwrV6"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Node",
|
||||
@@ -661,7 +661,7 @@
|
||||
"_is3DNode": false,
|
||||
"_groupIndex": 0,
|
||||
"groupIndex": 0,
|
||||
"_id": "c3XyfYRgRPB5iyAa58aSsW"
|
||||
"_id": "80Ey3vT8tOoKasdL4WSmVR"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Sprite",
|
||||
@@ -691,7 +691,7 @@
|
||||
"_fillRange": 0,
|
||||
"_isTrimmedMode": true,
|
||||
"_atlas": null,
|
||||
"_id": "8e55OmQuJIBYeXHoG9wTyk"
|
||||
"_id": "cfdPG7L1VJi5XF5TaYomyp"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Node",
|
||||
@@ -753,7 +753,7 @@
|
||||
"_is3DNode": false,
|
||||
"_groupIndex": 0,
|
||||
"groupIndex": 0,
|
||||
"_id": "d9CzwxVqJA5btSqQ2zxAtr"
|
||||
"_id": "0ccJcWYaxEw6CAV6LDgwBF"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Sprite",
|
||||
@@ -783,7 +783,7 @@
|
||||
"_fillRange": 0,
|
||||
"_isTrimmedMode": true,
|
||||
"_atlas": null,
|
||||
"_id": "28BN/vYpdA75aVQgtJV85T"
|
||||
"_id": "a2z7GHvbBJtbeFFKuZMp8r"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Node",
|
||||
@@ -845,7 +845,7 @@
|
||||
"_is3DNode": false,
|
||||
"_groupIndex": 0,
|
||||
"groupIndex": 0,
|
||||
"_id": "e1SVVBs6pDmI52ltKoFD6d"
|
||||
"_id": "f7EXG9BGNEv6AWXdMTqWbb"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Sprite",
|
||||
@@ -875,7 +875,7 @@
|
||||
"_fillRange": 0,
|
||||
"_isTrimmedMode": true,
|
||||
"_atlas": null,
|
||||
"_id": "025qCDItxA57ThVMG5sWtQ"
|
||||
"_id": "2aE+3035tDJqfns9wb+A8e"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Node",
|
||||
@@ -918,7 +918,7 @@
|
||||
"ctor": "Float64Array",
|
||||
"array": [
|
||||
0,
|
||||
150,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
@@ -940,7 +940,7 @@
|
||||
"_is3DNode": false,
|
||||
"_groupIndex": 0,
|
||||
"groupIndex": 0,
|
||||
"_id": "81cIITpURBEbMcOPB7cb6x"
|
||||
"_id": "2b4Sev3gxKqbyDuqgotK3s"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Label",
|
||||
@@ -973,7 +973,7 @@
|
||||
"_N$fontFamily": "Arial",
|
||||
"_N$overflow": 0,
|
||||
"_N$cacheMode": 0,
|
||||
"_id": "08NYYNx61NF42Hhp8PMtsi"
|
||||
"_id": "cbby0qHztEJKoa9kkCSPhN"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.LabelOutline",
|
||||
@@ -991,7 +991,7 @@
|
||||
"a": 255
|
||||
},
|
||||
"_width": 6,
|
||||
"_id": "caGnJok0NK/o3JsDAm2Z52"
|
||||
"_id": "9bWro31eJKybmJGCrePXSg"
|
||||
},
|
||||
{
|
||||
"__type__": "9285eM4YhBJhL8+C569X294",
|
||||
@@ -1030,12 +1030,12 @@
|
||||
},
|
||||
"_collideBoxOpacity": 100,
|
||||
"_isCustomLabelActive": true,
|
||||
"customComponentName": "Hero",
|
||||
"_customComponentName": "Hero",
|
||||
"_customLabelString": "坐标:x,y\n角度:angle,弧度:radian\n世界坐标:wp\nhp:#hp mp:#mp\n#equip.shoe.attr.speed",
|
||||
"_customLabelOffset": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0,
|
||||
"y": 150
|
||||
"y": 0
|
||||
},
|
||||
"_customLabelColor": {
|
||||
"__type__": "cc.Color",
|
||||
|
||||
Reference in New Issue
Block a user