Commit 4406b156 authored by 李帅's avatar 李帅

+1

parent f1eb499d
{
"ver": "1.1.0",
"uuid": "10d7986f-e45e-477c-a36c-013d0f2f6aa5",
"subMetas": {}
}
\ No newline at end of file
...@@ -102,25 +102,28 @@ ...@@ -102,25 +102,28 @@
"__id__": 74 "__id__": 74
}, },
{ {
"__id__": 77 "__id__": 79
}, },
{ {
"__id__": 82 "__id__": 82
}, },
{ {
"__id__": 101 "__id__": 87
},
{
"__id__": 106
} }
], ],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 105 "__id__": 110
}, },
{ {
"__id__": 106 "__id__": 111
}, },
{ {
"__id__": 107 "__id__": 112
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -1470,8 +1473,8 @@ ...@@ -1470,8 +1473,8 @@
"_opacity": 255, "_opacity": 255,
"_color": { "_color": {
"__type__": "cc.Color", "__type__": "cc.Color",
"r": 255, "r": 108,
"g": 96, "g": 185,
"b": 0, "b": 0,
"a": 255 "a": 255
}, },
...@@ -1584,7 +1587,9 @@ ...@@ -1584,7 +1587,9 @@
"__id__": 28 "__id__": 28
}, },
"_enabled": true, "_enabled": true,
"label": null, "label": {
"__id__": 29
},
"_id": "1711BQVPJEyr92fkrtWanD" "_id": "1711BQVPJEyr92fkrtWanD"
}, },
{ {
...@@ -3529,6 +3534,222 @@ ...@@ -3529,6 +3534,222 @@
"_N$target": null, "_N$target": null,
"_id": "9e5GNdvepIHbYhq6LvtapZ" "_id": "9e5GNdvepIHbYhq6LvtapZ"
}, },
{
"__type__": "cc.Node",
"_name": "bg_countdown",
"_objFlags": 0,
"_parent": {
"__id__": 2
},
"_children": [
{
"__id__": 75
}
],
"_active": false,
"_components": [
{
"__id__": 78
}
],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 106,
"height": 88
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
480,
-300,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "c7CUDdom5K5YDlYMAGbR3V"
},
{
"__type__": "cc.Node",
"_name": "label",
"_objFlags": 0,
"_parent": {
"__id__": 74
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 76
},
{
"__id__": 77
}
],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 83,
"g": 102,
"b": 138,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 29,
"height": 50.4
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
17,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "6abiL789BPerWWtIZfmrdi"
},
{
"__type__": "cc.Label",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 75
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_string": "1",
"_N$string": "1",
"_fontSize": 64,
"_lineHeight": 64,
"_enableWrapText": true,
"_N$file": {
"__uuid__": "10d7986f-e45e-477c-a36c-013d0f2f6aa5"
},
"_isSystemFontUsed": false,
"_spacingX": 0,
"_batchAsBitmap": false,
"_styleFlags": 0,
"_underlineHeight": 0,
"_N$horizontalAlign": 1,
"_N$verticalAlign": 1,
"_N$fontFamily": "Arial",
"_N$overflow": 0,
"_N$cacheMode": 0,
"_id": "ecV6SwS8tJc4bdYUZ+4U3o"
},
{
"__type__": "cc.LabelOutline",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 75
},
"_enabled": false,
"_color": {
"__type__": "cc.Color",
"r": 175,
"g": 7,
"b": 7,
"a": 255
},
"_width": 2,
"_id": "a06rt9gvBA6pOpJIH/gbN3"
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 74
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "8eda48c8-60ae-420e-b20a-734f2f05467a"
},
"_type": 0,
"_sizeMode": 1,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": "83wuxXc79J5YO1su9crcmM"
},
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "btn_record_stop", "_name": "btn_record_stop",
...@@ -3540,10 +3761,10 @@ ...@@ -3540,10 +3761,10 @@
"_active": false, "_active": false,
"_components": [ "_components": [
{ {
"__id__": 75 "__id__": 80
}, },
{ {
"__id__": 76 "__id__": 81
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -3599,7 +3820,7 @@ ...@@ -3599,7 +3820,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 74 "__id__": 79
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
...@@ -3631,7 +3852,7 @@ ...@@ -3631,7 +3852,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 74 "__id__": 79
}, },
"_enabled": true, "_enabled": true,
"_normalMaterial": null, "_normalMaterial": null,
...@@ -3703,16 +3924,16 @@ ...@@ -3703,16 +3924,16 @@
}, },
"_children": [ "_children": [
{ {
"__id__": 78 "__id__": 83
} }
], ],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 80 "__id__": 85
}, },
{ {
"__id__": 81 "__id__": 86
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -3768,13 +3989,13 @@ ...@@ -3768,13 +3989,13 @@
"_name": "label", "_name": "label",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 77 "__id__": 82
}, },
"_children": [], "_children": [],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 79 "__id__": 84
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -3830,7 +4051,7 @@ ...@@ -3830,7 +4051,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 78 "__id__": 83
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
...@@ -3863,7 +4084,7 @@ ...@@ -3863,7 +4084,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 77 "__id__": 82
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
...@@ -3895,7 +4116,7 @@ ...@@ -3895,7 +4116,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 77 "__id__": 82
}, },
"_enabled": true, "_enabled": true,
"alignMode": 1, "alignMode": 1,
...@@ -3926,25 +4147,25 @@ ...@@ -3926,25 +4147,25 @@
}, },
"_children": [ "_children": [
{ {
"__id__": 83 "__id__": 88
}, },
{ {
"__id__": 87 "__id__": 92
}, },
{ {
"__id__": 90 "__id__": 95
}, },
{ {
"__id__": 92 "__id__": 97
}, },
{ {
"__id__": 96 "__id__": 101
} }
], ],
"_active": false, "_active": false,
"_components": [ "_components": [
{ {
"__id__": 100 "__id__": 105
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -4000,19 +4221,19 @@ ...@@ -4000,19 +4221,19 @@
"_name": "mask", "_name": "mask",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 82 "__id__": 87
}, },
"_children": [], "_children": [],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 84 "__id__": 89
}, },
{ {
"__id__": 85 "__id__": 90
}, },
{ {
"__id__": 86 "__id__": 91
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -4068,7 +4289,7 @@ ...@@ -4068,7 +4289,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 83 "__id__": 88
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
...@@ -4100,7 +4321,7 @@ ...@@ -4100,7 +4321,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 83 "__id__": 88
}, },
"_enabled": true, "_enabled": true,
"alignMode": 1, "alignMode": 1,
...@@ -4127,7 +4348,7 @@ ...@@ -4127,7 +4348,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 83 "__id__": 88
}, },
"_enabled": true, "_enabled": true,
"_normalMaterial": null, "_normalMaterial": null,
...@@ -4195,16 +4416,16 @@ ...@@ -4195,16 +4416,16 @@
"_name": "bg", "_name": "bg",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 82 "__id__": 87
}, },
"_children": [], "_children": [],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 88 "__id__": 93
}, },
{ {
"__id__": 89 "__id__": 94
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -4260,7 +4481,7 @@ ...@@ -4260,7 +4481,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 87 "__id__": 92
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
...@@ -4292,7 +4513,7 @@ ...@@ -4292,7 +4513,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 87 "__id__": 92
}, },
"_enabled": true, "_enabled": true,
"_normalMaterial": null, "_normalMaterial": null,
...@@ -4353,7 +4574,7 @@ ...@@ -4353,7 +4574,7 @@
"hoverSprite": null, "hoverSprite": null,
"_N$disabledSprite": null, "_N$disabledSprite": null,
"_N$target": { "_N$target": {
"__id__": 87 "__id__": 92
}, },
"_id": "dbf6SlfeFJtqujsCK52/CR" "_id": "dbf6SlfeFJtqujsCK52/CR"
}, },
...@@ -4362,13 +4583,13 @@ ...@@ -4362,13 +4583,13 @@
"_name": "label", "_name": "label",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 82 "__id__": 87
}, },
"_children": [], "_children": [],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 91 "__id__": 96
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -4424,7 +4645,7 @@ ...@@ -4424,7 +4645,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 90 "__id__": 95
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
...@@ -4459,16 +4680,16 @@ ...@@ -4459,16 +4680,16 @@
"_name": "start", "_name": "start",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 82 "__id__": 87
}, },
"_children": [], "_children": [],
"_active": false, "_active": false,
"_components": [ "_components": [
{ {
"__id__": 93 "__id__": 98
}, },
{ {
"__id__": 94 "__id__": 99
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -4524,7 +4745,7 @@ ...@@ -4524,7 +4745,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 92 "__id__": 97
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
...@@ -4556,7 +4777,7 @@ ...@@ -4556,7 +4777,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 92 "__id__": 97
}, },
"_enabled": true, "_enabled": true,
"_normalMaterial": null, "_normalMaterial": null,
...@@ -4565,7 +4786,7 @@ ...@@ -4565,7 +4786,7 @@
"zoomScale": 1.2, "zoomScale": 1.2,
"clickEvents": [ "clickEvents": [
{ {
"__id__": 95 "__id__": 100
} }
], ],
"_N$interactable": true, "_N$interactable": true,
...@@ -4621,7 +4842,7 @@ ...@@ -4621,7 +4842,7 @@
"hoverSprite": null, "hoverSprite": null,
"_N$disabledSprite": null, "_N$disabledSprite": null,
"_N$target": { "_N$target": {
"__id__": 92 "__id__": 97
}, },
"_id": "f86X4c6OtP4K2F2ODiAK9B" "_id": "f86X4c6OtP4K2F2ODiAK9B"
}, },
...@@ -4640,16 +4861,16 @@ ...@@ -4640,16 +4861,16 @@
"_name": "restart", "_name": "restart",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 82 "__id__": 87
}, },
"_children": [], "_children": [],
"_active": false, "_active": false,
"_components": [ "_components": [
{ {
"__id__": 97 "__id__": 102
}, },
{ {
"__id__": 98 "__id__": 103
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -4705,7 +4926,7 @@ ...@@ -4705,7 +4926,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 96 "__id__": 101
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
...@@ -4737,7 +4958,7 @@ ...@@ -4737,7 +4958,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 96 "__id__": 101
}, },
"_enabled": true, "_enabled": true,
"_normalMaterial": null, "_normalMaterial": null,
...@@ -4746,7 +4967,7 @@ ...@@ -4746,7 +4967,7 @@
"zoomScale": 1.2, "zoomScale": 1.2,
"clickEvents": [ "clickEvents": [
{ {
"__id__": 99 "__id__": 104
} }
], ],
"_N$interactable": true, "_N$interactable": true,
...@@ -4821,7 +5042,7 @@ ...@@ -4821,7 +5042,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 82 "__id__": 87
}, },
"_enabled": true, "_enabled": true,
"alignMode": 1, "alignMode": 1,
...@@ -4852,7 +5073,7 @@ ...@@ -4852,7 +5073,7 @@
}, },
"_children": [ "_children": [
{ {
"__id__": 102 "__id__": 107
} }
], ],
"_active": true, "_active": true,
...@@ -4910,11 +5131,11 @@ ...@@ -4910,11 +5131,11 @@
"_name": "audio", "_name": "audio",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 101 "__id__": 106
}, },
"_children": [ "_children": [
{ {
"__id__": 103 "__id__": 108
} }
], ],
"_active": true, "_active": true,
...@@ -4972,13 +5193,13 @@ ...@@ -4972,13 +5193,13 @@
"_name": "btn", "_name": "btn",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 102 "__id__": 107
}, },
"_children": [], "_children": [],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 104 "__id__": 109
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -5034,7 +5255,7 @@ ...@@ -5034,7 +5255,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 103 "__id__": 108
}, },
"_enabled": true, "_enabled": true,
"_clip": { "_clip": {
...@@ -5107,7 +5328,7 @@ ...@@ -5107,7 +5328,7 @@
"__id__": 21 "__id__": 21
}, },
"tip": { "tip": {
"__id__": 82 "__id__": 87
}, },
"_id": "eaTVUpqahPfZeO9+sUI7RP" "_id": "eaTVUpqahPfZeO9+sUI7RP"
} }
......
/* /*
* @Author: ls * @Author: ls
* @Date: 2022-05-15 18:22:18 * @Date: 2022-05-15 18:22:18
* @LastEditTime: 2022-05-23 15:25:56 * @LastEditTime: 2022-05-31 21:56:35
* @LastEditors: ls * @LastEditors: ls
* @Description: * @Description:
* @FilePath: \ls_gramophone\assets\ls_gramophone\scene\ls_gramophone.ts * @FilePath: \ls_gramophone\assets\ls_gramophone\scene\ls_gramophone.ts
...@@ -27,6 +27,8 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -27,6 +27,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
_recording = false; _recording = false;
// 录音音频 // 录音音频
_records = []; _records = [];
// 倒计时
_countdown = 30;
addPreloadImage() { addPreloadImage() {
// TODO 根据自己的配置预加载图片资源 // TODO 根据自己的配置预加载图片资源
...@@ -176,8 +178,10 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -176,8 +178,10 @@ export default class SceneComponent extends MyCocosSceneComponent {
let record_start = cc.find('Canvas/btn_record_start'); let record_start = cc.find('Canvas/btn_record_start');
let record_stop = cc.find('Canvas/btn_record_stop'); let record_stop = cc.find('Canvas/btn_record_stop');
let countdown = cc.find('Canvas/bg_countdown');
record_start.active = false; record_start.active = false;
record_stop.active = false; record_stop.active = false;
countdown.active = false;
record_start.off('click'); record_start.off('click');
record_stop.off('click'); record_stop.off('click');
record_start.on('click', () => { record_start.on('click', () => {
...@@ -188,6 +192,12 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -188,6 +192,12 @@ export default class SceneComponent extends MyCocosSceneComponent {
record_start.active = false; record_start.active = false;
record_stop.active = true; record_stop.active = true;
countdown.active = true;
this.unschedule(this.onCountdown);
this._countdown = 30 + 1;
this.onCountdown();
this.schedule(this.onCountdown, 1);
this._recording = true; this._recording = true;
...@@ -203,6 +213,9 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -203,6 +213,9 @@ export default class SceneComponent extends MyCocosSceneComponent {
record_start.active = false; record_start.active = false;
record_stop.active = false; record_stop.active = false;
countdown.active = false;
this.unschedule(this.onCountdown);
this._recording = false; this._recording = false;
...@@ -302,6 +315,31 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -302,6 +315,31 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.tip.active = false; this.tip.active = false;
} }
/**
* 倒计时回调
*/
onCountdown() {
this._countdown--;
if (this._countdown <= 0) {
let record_stop = cc.find('Canvas/btn_record_stop');
record_stop.emit('click');
this.unschedule(this.onCountdown);
} else {
let bg_countdown_label = cc.find('Canvas/bg_countdown/label');
bg_countdown_label.getComponent(cc.Label).string = this._countdown + '';
if (this._countdown > 9) {
bg_countdown_label.color = cc.color(83, 102, 138);
bg_countdown_label.getComponent(cc.Label).fontSize = 50;
bg_countdown_label.getComponent(cc.LabelOutline).enabled = false;
} else {
bg_countdown_label.color = cc.color(255, 132, 132);
bg_countdown_label.getComponent(cc.Label).fontSize = 64;
bg_countdown_label.getComponent(cc.LabelOutline).enabled = true;
}
}
}
onCallBack(event: cc.Event.EventTouch, str: string) { onCallBack(event: cc.Event.EventTouch, str: string) {
this.playLocalAudio('btn'); this.playLocalAudio('btn');
if (str === 'start' || str === 'restart') { if (str === 'start' || str === 'restart') {
......
/* /*
* @Author: ls * @Author: ls
* @Date: 2022-05-21 21:59:51 * @Date: 2022-05-21 21:59:51
* @LastEditTime: 2022-05-22 17:32:48 * @LastEditTime: 2022-05-31 21:15:17
* @LastEditors: ls * @LastEditors: ls
* @Description: * @Description:
* @FilePath: \ls_gramophone\assets\ls_gramophone\script\Item.ts * @FilePath: \ls_gramophone\assets\ls_gramophone\script\Item.ts
...@@ -142,7 +142,8 @@ export default class Item extends cc.Component { ...@@ -142,7 +142,8 @@ export default class Item extends cc.Component {
*/ */
playing() { playing() {
this.tip.active = true; this.tip.active = true;
this.label.node.color = cc.color(255, 96, 0); // this.label.node.color = cc.color(255, 96, 0);
this.label.node.color = cc.color(108, 185, 0);
} }
/** /**
......
/* /*
* @Author: ls * @Author: ls
* @Date: 2022-05-21 18:06:20 * @Date: 2022-05-21 18:06:20
* @LastEditTime: 2022-05-21 22:00:56 * @LastEditTime: 2022-05-31 22:45:56
* @LastEditors: ls * @LastEditors: ls
* @Description: * @Description:
* @FilePath: \ls_gramophone\assets\ls_gramophone\script\simpleLabel.ts * @FilePath: \ls_gramophone\assets\ls_gramophone\script\simpleLabel.ts
...@@ -26,6 +26,9 @@ export default class simpleLabel extends cc.Component { ...@@ -26,6 +26,9 @@ export default class simpleLabel extends cc.Component {
// 目标字符串行数 // 目标字符串行数
private _rows = 0; private _rows = 0;
// 目标宽度
private _targetWidget = 0;
// TODO 字符数组(后期处理标点符号) // TODO 字符数组(后期处理标点符号)
private _characters = [',', '.']; private _characters = [',', '.'];
...@@ -48,6 +51,7 @@ export default class simpleLabel extends cc.Component { ...@@ -48,6 +51,7 @@ export default class simpleLabel extends cc.Component {
} }
} }
this._targetWidget = targetWidget;
// 保存源字符串 // 保存源字符串
this._sourceString = sourceString; this._sourceString = sourceString;
// 保存源字符串数组(根据空格分割) // 保存源字符串数组(根据空格分割)
...@@ -129,4 +133,55 @@ export default class simpleLabel extends cc.Component { ...@@ -129,4 +133,55 @@ export default class simpleLabel extends cc.Component {
let width = (metric && metric.width) || 0; let width = (metric && metric.width) || 0;
return width; return width;
} }
/**
* 获取所有字符串的位置
* @param str
* @returns
*/
getTargetStringPos(str: string) {
let poss = [];
let rows = 0;
let lastString = '';
if (this._sourceArray && this._sourceArray.length) {
for (let index = 0; index < this._sourceArray.length; index++) {
let element = this._sourceArray[index];
// 临时字符串
let tempString = lastString;
if (lastString === '') {
lastString = element; // 设置字符串
} else {
lastString = lastString + ' ' + element; // 添加字符串
}
// 如果字符串长度 >= 设计字符串长度
if (this.getLetterWidth(this.label, lastString) >= this._targetWidget) {
// 增加行数
lastString = element;
tempString = '';
rows++;
}
let temp = element;
if (element.indexOf(',') !== -1) {
temp.substring(element.indexOf(','), 1);
} else if (element.indexOf('.') !== -1) {
temp.substring(element.indexOf('.'), 1);
} else if (element.indexOf('!') !== -1) {
temp.substring(element.indexOf('!'), 1);
} else if (element.indexOf('?') !== -1) {
temp.substring(element.indexOf('?'), 1);
}
if (temp === str) {
poss.push(rows, this.getLetterWidth(this.label, tempString), this.getLetterWidth(this.label, str));
}
}
}
return poss;
}
} }
{
"ver": "2.3.5",
"uuid": "9e70c229-d350-46dc-9f44-ac254d4352e9",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 106,
"height": 88,
"platformSettings": {},
"subMetas": {
"bg_countdown": {
"ver": "1.0.4",
"uuid": "8eda48c8-60ae-420e-b20a-734f2f05467a",
"rawTextureUuid": "9e70c229-d350-46dc-9f44-ac254d4352e9",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 106,
"height": 88,
"rawWidth": 106,
"rawHeight": 88,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment