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
/*
* @Author: ls
* @Date: 2022-05-15 18:22:18
* @LastEditTime: 2022-05-23 15:25:56
* @LastEditTime: 2022-05-31 21:56:35
* @LastEditors: ls
* @Description:
* @FilePath: \ls_gramophone\assets\ls_gramophone\scene\ls_gramophone.ts
......@@ -27,6 +27,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
_recording = false;
// 录音音频
_records = [];
// 倒计时
_countdown = 30;
addPreloadImage() {
// TODO 根据自己的配置预加载图片资源
......@@ -176,8 +178,10 @@ export default class SceneComponent extends MyCocosSceneComponent {
let record_start = cc.find('Canvas/btn_record_start');
let record_stop = cc.find('Canvas/btn_record_stop');
let countdown = cc.find('Canvas/bg_countdown');
record_start.active = false;
record_stop.active = false;
countdown.active = false;
record_start.off('click');
record_stop.off('click');
record_start.on('click', () => {
......@@ -188,6 +192,12 @@ export default class SceneComponent extends MyCocosSceneComponent {
record_start.active = false;
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;
......@@ -203,6 +213,9 @@ export default class SceneComponent extends MyCocosSceneComponent {
record_start.active = false;
record_stop.active = false;
countdown.active = false;
this.unschedule(this.onCountdown);
this._recording = false;
......@@ -302,6 +315,31 @@ export default class SceneComponent extends MyCocosSceneComponent {
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) {
this.playLocalAudio('btn');
if (str === 'start' || str === 'restart') {
......
/*
* @Author: ls
* @Date: 2022-05-21 21:59:51
* @LastEditTime: 2022-05-22 17:32:48
* @LastEditTime: 2022-05-31 21:15:17
* @LastEditors: ls
* @Description:
* @FilePath: \ls_gramophone\assets\ls_gramophone\script\Item.ts
......@@ -142,7 +142,8 @@ export default class Item extends cc.Component {
*/
playing() {
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
* @Date: 2022-05-21 18:06:20
* @LastEditTime: 2022-05-21 22:00:56
* @LastEditTime: 2022-05-31 22:45:56
* @LastEditors: ls
* @Description:
* @FilePath: \ls_gramophone\assets\ls_gramophone\script\simpleLabel.ts
......@@ -26,6 +26,9 @@ export default class simpleLabel extends cc.Component {
// 目标字符串行数
private _rows = 0;
// 目标宽度
private _targetWidget = 0;
// TODO 字符数组(后期处理标点符号)
private _characters = [',', '.'];
......@@ -48,6 +51,7 @@ export default class simpleLabel extends cc.Component {
}
}
this._targetWidget = targetWidget;
// 保存源字符串
this._sourceString = sourceString;
// 保存源字符串数组(根据空格分割)
......@@ -129,4 +133,55 @@ export default class simpleLabel extends cc.Component {
let width = (metric && metric.width) || 0;
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