create project

This commit is contained in:
szrpf
2023-04-22 02:25:25 +08:00
commit 59723fbd8e
439 changed files with 64943 additions and 0 deletions

13
assets/Scene.meta Normal file
View File

@@ -0,0 +1,13 @@
{
"ver": "1.1.3",
"uuid": "29f52784-2fca-467b-92e7-8fd9ef8c57b7",
"importer": "folder",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}

1229
assets/Scene/helloworld.fire Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,8 @@
{
"ver": "1.3.2",
"uuid": "2d2f792f-a40c-49bb-a189-ed176a246e49",
"importer": "scene",
"asyncLoadAssets": false,
"autoReleaseAssets": false,
"subMetas": {}
}

13
assets/Script.meta Normal file
View File

@@ -0,0 +1,13 @@
{
"ver": "1.1.3",
"uuid": "4734c20c-0db8-4eb2-92ea-e692f4d70934",
"importer": "folder",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}

311
assets/Script/DataBoard.ts Normal file
View File

@@ -0,0 +1,311 @@
/*******************************************************************************
* 创建: 2022年11月23日
* 作者: 水煮肉片饭(27185709@qq.com)
* 描述: 数据看板
* 节点挂上该组件,就可以在游戏运行过程中,直观看到节点任意属性(包括节点脚本中的属性)
* 可以图形化展示以下四种数据:
* 轮廓盒子: 随节点旋转,代表节点的实时矩形
* 碰撞盒子: 不随节点旋转,一般代表碰撞范围
* 自定义参数: 节点自身属性,以及节点任意脚本中的属性
* 锚点: 锚点位置会显示一个小红点
* 自定义参数(配置想监控的数据):
* wp 世界坐标,即相对于屏幕左下角的坐标
* radian 节点弧度,单位π
* matrix: 变换矩阵
* parent 父节点
* children 子节点
* 自身属性: scale,width,opacity等
* 脚本属性: 脚本实例对象的属性
* ————————————————————————举个栗子————————————————————————
* 脚本: Hero
* 参数: wp,scale,angle,#angle,#hp用英文逗号或回车分隔
* 显示结果:世界坐标,节点scale,节点angleHero对象的angle,Hero对象的hp
* ————————————————————————温馨提示————————————————————————
* 初始化的时候设置全局变量window['DATABOARD'] = false可屏蔽本项目所有DataBoard不会产生任何额外开销\n
*******************************************************************************/
window['DATABOARD'] = true;
const ANCHOR_SIZE = 20; //锚点的大小
const LINEHEIGHT = 1.2; //行高是字体大小的多少倍
const { ccclass, property, executeInEditMode, menu } = cc._decorator;
@ccclass
@executeInEditMode
@menu('Component/DataBoard')
export default class DataBoard extends cc.Component {
@property
private _isOutlineBoxActive: boolean = false;
@property({ displayName: CC_DEV && '轮廓盒子', tooltip: CC_DEV && '随节点旋转,代表实时轮廓' })
private get isOutlineBoxActive() { return this._isOutlineBoxActive };
private set isOutlineBoxActive(value: boolean) {
this._isOutlineBoxActive = value;
this.outlineBoxNode.active = value;
}
@property
private _outlineBoxColor: cc.Color = new cc.Color(Math.random() * 255, Math.random() * 255, Math.random() * 255);
@property({ displayName: CC_DEV && '······颜色', visible() { return this.isOutlineBoxActive } })
private get outlineBoxColor() { return this._outlineBoxColor };
private set outlineBoxColor(value: cc.Color) {
this._outlineBoxColor = value;
this.outlineBoxNode.color = value;
}
@property
private _outlineBoxOpacity: number = 100;
@property({ min: 0, max: 255, step: 1, slide: true, displayName: CC_DEV && '······透明度', visible() { return this.isOutlineBoxActive } })
private get outlineBoxOpacity() { return this._outlineBoxOpacity };
private set outlineBoxOpacity(value: number) {
this._outlineBoxOpacity = value;
this.outlineBoxNode.opacity = value;
}
@property
private _isCollideBoxActive: boolean = true;
@property({ displayName: CC_DEV && '碰撞盒子', tooltip: CC_DEV && '不随节点旋转,代表碰撞范围' })
private get isCollideBoxActive() { return this._isCollideBoxActive };
private set isCollideBoxActive(value: boolean) {
this._isCollideBoxActive = value;
this.collideBoxNode.active = value;
}
@property
private _collideBoxColor: cc.Color = new cc.Color(Math.random() * 255, Math.random() * 255, Math.random() * 255);
@property({ displayName: CC_DEV && '······颜色', visible() { return this.isCollideBoxActive } })
private get collideBoxColor() { return this._collideBoxColor };
private set collideBoxColor(value: cc.Color) {
this._collideBoxColor = value;
this.collideBoxNode.color = value;
}
@property
private _collideBoxOpacity: number = 100;
@property({ min: 0, max: 255, step: 1, slide: true, displayName: CC_DEV && '······透明度', visible() { return this.isCollideBoxActive } })
private get collideBoxOpacity() { return this._collideBoxOpacity };
private set collideBoxOpacity(value: number) {
this._collideBoxOpacity = value;
this.collideBoxNode.opacity = value;
}
@property
private _isCustomLabelActive: boolean = true;
@property({ displayName: CC_DEV && '自定义参数', tooltip: CC_DEV && '配置显示的属性内容' })
private get isCustomLabelActive() { return this._isCustomLabelActive };
private set isCustomLabelActive(value: boolean) {
this._isCustomLabelActive = value;
this.customLabelNode.active = value;
}
@property({ displayName: CC_DEV && '······脚本', tooltip: CC_DEV && '监控哪个脚本', visible() { return this.isCustomLabelActive; } })
private customComponentName: string = '';
@property
private _customLabelString: string = 'x,y';
@property({ multiline: true, displayName: CC_DEV && '······参数', tooltip: CC_DEV && "—————支持的参数————\nwp世界坐标\nradian角度单位π\nmatrix变换矩阵\nparent父节点\nchildren子节点\n自身属性scale,width,opacity等\n脚本属性脚本实例对象的属性\n————举个栗子————\n脚本Hero\n参数wp,scale,angle,#angle,#hp\n↑↑↑用英文逗号或回车分隔↑↑↑\n显示结果\n世界坐标,节点scale,节点angleHero对象的angle,Hero对象的hp\n————温馨提示————\n初始化的时候设置全局变量\nwindow['DATABOARD'] = false\n可屏蔽本项目所有DataBoard不会产生任何额外开销", visible() { return this.isCustomLabelActive } })
private get customLabelString() { return this._customLabelString };
private set customLabelString(value: string) {
this._customLabelString = value;
this.customLabelStringSplit = value
.replace(/,/g, '_~_').replace(/:/g, '_!_').replace(/ /g, '_@_')
.replace(/([^,])\n/g, '$1_\n').replace(/\n([^,])/g, '\n_$1')
.replace(/([^:])\n/g, '$1_\n').replace(/\n([^:])/g, '\n_$1')
.replace(/([^ ])\n/g, '$1_\n').replace(/\n([^ ])/g, '\n_$1')
.split('_');
}
@property
private _customLabelOffset: cc.Vec2 = cc.v2(0, 100);
@property({ displayName: CC_DEV && '······偏移', visible() { return this.isCustomLabelActive } })
private get customLabelOffset() { return this._customLabelOffset };
private set customLabelOffset(value: cc.Vec2) {
this._customLabelOffset = value;
this.customLabelNode.x = value.x;
this.customLabelNode.y = value.y;
}
@property
private _customLabelColor: cc.Color = new cc.Color(255, 255, 0);
@property({ displayName: CC_DEV && '······颜色', visible() { return this.isCustomLabelActive } })
private get customLabelColor() { return this._customLabelColor };
private set customLabelColor(value: cc.Color) {
this._customLabelColor = value;
this.customLabelNode.color = value;
}
@property
private _customLabelSize: number = 60;
@property({ displayName: CC_DEV && '······大小', visible() { return this.isCustomLabelActive } })
private get customLabelSize() { return this._customLabelSize };
private set customLabelSize(value: number) {
this._customLabelSize = value;
this.customLabel.fontSize = value;
this.customLabel.lineHeight = value*LINEHEIGHT;
this.customLabelNode.getComponent(cc.LabelOutline).width = value * 0.1;
}
@property
private _customLabelDigit: number = 0;
@property({ min: 0, max: 10, step: 1, slide: true, displayName: CC_DEV && '······小数位数', visible() { return this.isCustomLabelActive } })
private get customLabelDigit() { return this._customLabelDigit };
private set customLabelDigit(value: number) {
this._customLabelDigit = value;
}
private boardNode: cc.Node = null;
private outlineBoxNode: cc.Node = null;
private collideBoxNode: cc.Node = null;
private anchorPointNode: cc.Node = null;
private customLabelNode: cc.Node = null;
private customLabel: cc.Label = null;
private customLabelStringSplit: string[] = null;
private monitorComp: cc.Component = null;
protected onLoad() {
this.boardNode = this.node.getChildByName('DataBoard');
if (!CC_EDITOR && !window['DATABOARD']) {
this.destroy();
return;
}
if (cc.isValid(this.boardNode)) {
this.boardNode.removeFromParent();
this.boardNode.destroy();
}
let 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;
this.outlineBoxNode = new cc.Node('OutlineBox');
this.outlineBoxNode.setParent(this.boardNode);
this.outlineBoxNode.addComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture);
this.outlineBoxNode.active = this.isOutlineBoxActive;
this.outlineBoxNode.color = this.outlineBoxColor;
this.outlineBoxNode.opacity = this.outlineBoxOpacity;
this.collideBoxNode = new cc.Node('CollideBox');
this.collideBoxNode.setParent(this.boardNode);
this.collideBoxNode.addComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture);
this.collideBoxNode.active = this.isCollideBoxActive;
this.collideBoxNode.color = this.collideBoxColor;
this.collideBoxNode.opacity = this.collideBoxOpacity;
this.anchorPointNode = new cc.Node('AnchorPoint');
this.anchorPointNode.setParent(this.boardNode);
this.anchorPointNode.addComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture);
this.anchorPointNode.color = cc.color(255, 0, 0);
this.anchorPointNode.width = ANCHOR_SIZE;
this.anchorPointNode.height = ANCHOR_SIZE;
this.customLabelNode = new cc.Node('CustomLabel');
this.customLabelNode.setParent(this.boardNode);
this.customLabel = this.customLabelNode.addComponent(cc.Label);
this.customLabelNode.addComponent(cc.LabelOutline).color = cc.color(0, 0, 0);
this.customLabelNode.active = this.isCustomLabelActive;
this.customLabelString = this._customLabelString;
this.customLabelNode.x = this.customLabelOffset.x;
this.customLabelNode.y = this.customLabelOffset.y;
this.customLabelNode.color = this.customLabelColor;
this.customLabelSize = this._customLabelSize;
this.updateAngle();
this.updateScale();
this.updateAnchor();
this.updateSize();
this.node.on(cc.Node.EventType.ROTATION_CHANGED, this.updateAngle, this);
this.node.on(cc.Node.EventType.SCALE_CHANGED, this.updateScale, this);
this.node.on(cc.Node.EventType.ANCHOR_CHANGED, this.updateAnchor, this);
this.node.on(cc.Node.EventType.SIZE_CHANGED, this.updateSize, this);
}
private updateAngle() {
this.collideBoxNode.angle = -this.node.angle;
this.customLabelNode.angle = -this.node.angle;
}
private updateScale() {
this.boardNode.scaleX = 1 / this.node.scaleX;
this.boardNode.scaleY = 1 / this.node.scaleY;
this.outlineBoxNode.scaleX = this.node.scaleX;
this.outlineBoxNode.scaleY = this.node.scaleY;
this.collideBoxNode.scaleX = this.node.scaleX;
this.collideBoxNode.scaleY = this.node.scaleY;
}
private updateAnchor() {
this.outlineBoxNode.anchorX = this.node.anchorX;
this.outlineBoxNode.anchorY = this.node.anchorY;
this.collideBoxNode.anchorX = this.node.anchorX;
this.collideBoxNode.anchorY = this.node.anchorY;
}
private updateSize() {
this.outlineBoxNode.width = this.node.width;
this.outlineBoxNode.height = this.node.height;
this.collideBoxNode.width = this.node.width;
this.collideBoxNode.height = this.node.height;
}
protected update() {
if (!this.isCustomLabelActive) return;
if (!this.customLabelStringSplit) return;
let str = '';
let strs = this.customLabelStringSplit;
if (!this.monitorComp && this.customComponentName) {
this.monitorComp = this.node.getComponent(this.customComponentName);
}
for (let i = 0, len = strs.length; i < len; ++i) {
let tmp = null;
switch (strs[i]) {
case 'wp':
let pos = this.node.convertToWorldSpaceAR(cc.v2(0, 0));
tmp = `(${pos.x.toFixed(this.customLabelDigit)},\t${pos.y.toFixed(this.customLabelDigit)})`;
break;
case 'angle':
tmp = this.node.angle.toFixed(this.customLabelDigit) + '°';
break;
case 'radian':
tmp = (this.node.angle / 180).toFixed(this.customLabelDigit) + 'π';
break;
case 'matrix':
let matrix = this.node['_worldMatrix'].m;
tmp = '';
for (let i = 0; i < 4; ++i) {
for (let j = 0; j < 4; ++j) {
let mm = matrix[j * 4 + i];
tmp += (mm < 0 ? '\t\t' : '\t\t\t') + mm.toFixed(this.customLabelDigit);
}
if (i !== 3) tmp += '\n';
}
break;
case 'parent':
tmp = this.node.parent.name;
break;
case 'children':
tmp = '';
for (let i = 0, len = this.node.childrenCount; i < len; ++i) {
tmp += `\t\t\t${i}${this.node.children[i].name}`;
if (i !== len - 1) tmp += '\n';
}
break;
case '~': tmp = ',\t'; break;
case '!': tmp = ':\t'; break;
case '@': tmp = ' \t'; break;
default:
if (this.node[strs[i]] !== undefined) {
tmp = this.node[strs[i]];
} else if (strs[i].startsWith('#') && this.monitorComp !== null) {
tmp = this.monitorComp[strs[i].substring(1)];
} else {
tmp = strs[i];
}
if (tmp && tmp.name) {
tmp = tmp.name;
}
break;
}
if (typeof tmp === 'number') {
tmp = tmp.toFixed(this.customLabelDigit);
}
str += tmp;
}
this.customLabel.string = str;
}
protected onDestroy() {
if (cc.isValid(this.boardNode)) {
this.boardNode.removeFromParent();
this.boardNode.destroy();
};
this.node.targetOff(this);
}
}

View File

@@ -0,0 +1,10 @@
{
"ver": "1.1.0",
"uuid": "1c1526d4-850a-49e8-9d63-1a14155187fc",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

13
assets/Script/Hero.ts Normal file
View File

@@ -0,0 +1,13 @@
const {ccclass, property} = cc._decorator;
@ccclass
export default class Helloworld extends cc.Component {
hp = 100;
mp = 60;
update (dt) {
this.hp += 1.0*dt;
this.mp += 0.5*dt;
}
}

View File

@@ -0,0 +1,10 @@
{
"ver": "1.1.0",
"uuid": "9285e338-6210-4984-bf3e-0b9ebd5f6f78",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

13
assets/Texture.meta Normal file
View File

@@ -0,0 +1,13 @@
{
"ver": "1.1.3",
"uuid": "7b81d4e8-ec84-4716-968d-500ac1d78a54",
"importer": "folder",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 B

View File

@@ -0,0 +1,38 @@
{
"ver": "2.3.7",
"uuid": "a8027877-d8d6-4645-97a0-52d4a0123dba",
"importer": "texture",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 2,
"height": 2,
"platformSettings": {},
"subMetas": {
"singleColor": {
"ver": "1.0.6",
"uuid": "410fb916-8721-4663-bab8-34397391ace7",
"importer": "sprite-frame",
"rawTextureUuid": "a8027877-d8d6-4645-97a0-52d4a0123dba",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 2,
"height": 2,
"rawWidth": 2,
"rawHeight": 2,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

View File

@@ -0,0 +1,38 @@
{
"ver": "2.3.7",
"uuid": "70364224-9941-46cb-9c14-263fa45363b9",
"importer": "texture",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 170,
"height": 153,
"platformSettings": {},
"subMetas": {
"zhizhuxia": {
"ver": "1.0.6",
"uuid": "6e0882b8-ac14-4ee7-b636-cb22032c50b1",
"importer": "sprite-frame",
"rawTextureUuid": "70364224-9941-46cb-9c14-263fa45363b9",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 170,
"height": 153,
"rawWidth": 170,
"rawHeight": 153,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}

88
assets/cocos.anim Normal file
View File

@@ -0,0 +1,88 @@
{
"__type__": "cc.AnimationClip",
"_name": "cocos",
"_objFlags": 0,
"_native": "",
"_duration": 2.5,
"sample": 60,
"speed": 0.1,
"wrapMode": 2,
"curveData": {
"props": {
"position": [],
"angle": [],
"scale": []
},
"paths": {
"挂上DataBoard的对象": {
"props": {
"position": [
{
"frame": 0,
"value": [
0,
50,
0
]
},
{
"frame": 0.5,
"value": [
-169.683,
414.072,
0
]
},
{
"frame": 1,
"value": [
-203.071,
-538.46,
0
]
},
{
"frame": 1.5,
"value": [
247.091,
323.062,
0
]
},
{
"frame": 2,
"value": [
215.112,
-535.196,
0
]
},
{
"frame": 2.5,
"value": [
0,
50,
0
]
}
],
"angle": [
{
"frame": 0,
"value": 0
},
{
"frame": 1,
"value": 720
},
{
"frame": 2.5,
"value": 0
}
]
}
}
}
},
"events": []
}

6
assets/cocos.anim.meta Normal file
View File

@@ -0,0 +1,6 @@
{
"ver": "2.1.2",
"uuid": "e68a8476-8374-4400-ae48-d3eae5df38ea",
"importer": "animation-clip",
"subMetas": {}
}