Commit 1125a0b3 authored by Tt's avatar Tt
parents 7233d4c1 1acd3561
This diff is collapsed.
{
"ver": "1.2.9",
"uuid": "35fbe4f1-249e-4263-90a1-de923c148363",
"optimizationPolicy": "AUTO",
"asyncLoadAssets": false,
"readonly": false,
"subMetas": {}
}
\ No newline at end of file
......@@ -6,48 +6,76 @@ let win: any = window;
let courseware = win.courseware;
@ccclass
export default class LayerRecord extends cc.Component {
@property(cc.Label)
label: cc.Label = null;
@property
text: string = 'hello';
// LIFE-CYCLE CALLBACKS:
onLoad() { }
start() {
private layout_record: cc.Node;
onLoad() {
this.layout_record = pg.view.find(this, 'layout_record')
let AniNode = pg.view.find(this.layout_record, 'AniNode');
AniNode.active = false;
let btn_play = pg.view.find(this.layout_record, 'btn_play');
btn_play.active = false;
this.initEvent();
pg.event.emit('layer_record_setting', {
letter: 'test',
targetTime: 10
})
}
private letter: string;
private targetTime: number;
initEvent() {
pg.event.on('layer_record_setting', (data) => {
this.letter = data.letter
this.targetTime = data.targetTime
})
let btn_record = pg.view.find(this.layout_record, 'btn_record');
btn_record.on(cc.Node.EventType.TOUCH_START, this.onTouchRecord, this);
btn_record.on(cc.Node.EventType.TOUCH_END, this.onTouchRecordEnd, this);
}
showVoiceWhite() {
let voice_white = pg.view.find(this.layout_record, 'voice_white');
cc.tween(voice_white).set({ scale: 1, opacity: 255 }).to(1, { scale: 1.5, opacity: 0 }).delay(0.5).union().repeatForever().start();
}
private startTime: number;
showTimeStart() {
if (!this.targetTime) return;
let nowTime = new Date().getTime();
this.startTime = nowTime;
}
showTimeUpdate() {
if (!this.startTime) return;
let nowTime = new Date().getTime();
let subTime = (nowTime - this.startTime) / 1000;
let percent = 1 - (subTime / this.targetTime);
percent = Math.max(percent, 0)
let record_time = pg.view.find(this.layout_record, 'record_time');
record_time.getComponent(cc.Sprite).fillRange = percent;
if (percent == 0) {
this.showTimeEnd();
}
}
showTimeEnd() {
this.startTime = null;
let record_time = pg.view.find(this.layout_record, 'record_time');
record_time.getComponent(cc.Sprite).fillRange = 0;
}
protected update(dt: number): void {
this.showTimeUpdate();
}
//按钮触发,使用的方法
async onTouchRecord() {
let ske = pg.view.find(this.layout_speak, 'speak_ske');
let btn_start = pg.view.find(this.layout_speak, 'btn_start');
let btn_stop = pg.view.find(this.layout_speak, 'btn_stop');
btn_start.active = false;
btn_stop.active = true;
ske.getComponent(dragonBones.ArmatureDisplay).timeScale = 1;
cc.audioEngine.stopAllEffects();
let AniNode = pg.view.find(this.layout_record, 'AniNode');
AniNode.active = true;
this.showTimeStart();
let end = pg.view.find(this, "end");
let bg_tryagain = pg.view.find(end, "bg_tryagain")
pg.view.visible(end, false);
pg.view.visible(bg_tryagain, false);
courseware && courseware.startTest(this.touchData.txt); //开始录音
cc.audioEngine.stopAllEffects();
courseware && courseware.startTest(this.letter); //开始录音
}
async onTouchRecordEnd() {
let ske = pg.view.find(this.layout_speak, 'speak_ske');
let btn_start = pg.view.find(this.layout_speak, 'btn_start');
let btn_stop = pg.view.find(this.layout_speak, 'btn_stop');
pg.view.playDBAnimation(ske, 'newAnimation', 1);
ske.getComponent(dragonBones.ArmatureDisplay).timeScale = 10000;
btn_stop.active = false;
btn_start.active = false;
let AniNode = pg.view.find(this.layout_record, 'AniNode');
AniNode.active = false;
this.showTimeEnd();
let testData = {
"dtLastResponse": "2021-09-17 13:36:26:109",
"refText": "I haven't found anything out about him yet.",
......@@ -69,38 +97,13 @@ export default class LayerRecord extends cc.Component {
"applicationId": "154838659000009e"
}
if (!courseware) return this.recrodEnd(testData)
// await pg.time.delay(5);
courseware && courseware.stopTest((data) => {
data = JSON.parse(data);
this.recrodEnd(data);
}); //结束录音
}
private tryData: Array<Option>;
async recrodEnd(data) {
Game.getIns().player.addVoice(data);
let score = data.result.overall;
if (score >= 80) {
//提示成功
this.updateTips(TIPS_STATE.GOOD);
Game.getIns().player.addRight();
this.touchFishs.push(this.touchData);
} else {
//提示失败
if (this.tryData.some(td => td.id == this.touchData.id)) {
this.updateTips(TIPS_STATE.COM);
this.touchFishs.push(this.touchData);
} else {
this.updateTips(TIPS_STATE.TRY);
this.tryData.push(this.touchData);
this.viewFishs = this.viewFishs.filter(v => v.id != this.touchData.id);
}
}
await pg.time.delay(3);
this.updateTips(null);
this.playCard(null);
this.updateLayoutSpeak(true)
this.touching = false;
pg.event.on('layer_record_score', score);
}
// update (dt) {}
}
{
"ver": "2.3.5",
"uuid": "dd5d53aa-0ec7-4476-a807-42f251d89b87",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 150,
"height": 150,
"platformSettings": {},
"subMetas": {
"p0": {
"ver": "1.0.4",
"uuid": "c9eb055f-e3e0-4f6e-9e05-45d7c4608877",
"rawTextureUuid": "dd5d53aa-0ec7-4476-a807-42f251d89b87",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 23,
"trimY": 23,
"width": 104,
"height": 104,
"rawWidth": 150,
"rawHeight": 150,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "422dcc2c-0347-46ab-88d9-a167e71390ac",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 150,
"height": 150,
"platformSettings": {},
"subMetas": {
"p1": {
"ver": "1.0.4",
"uuid": "84c11178-f263-4e14-aa51-104545bb5499",
"rawTextureUuid": "422dcc2c-0347-46ab-88d9-a167e71390ac",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 23,
"trimY": 23,
"width": 104,
"height": 104,
"rawWidth": 150,
"rawHeight": 150,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "27ef14bc-6d9a-4418-b9be-57fa7debf46f",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 150,
"height": 150,
"platformSettings": {},
"subMetas": {
"p2": {
"ver": "1.0.4",
"uuid": "79273752-abd4-4f1c-90d6-790e6a7d507c",
"rawTextureUuid": "27ef14bc-6d9a-4418-b9be-57fa7debf46f",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 23,
"trimY": 23,
"width": 104,
"height": 104,
"rawWidth": 150,
"rawHeight": 150,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "0a711ec1-92b8-4ff7-b0f5-feb00b6a2c24",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 150,
"height": 150,
"platformSettings": {},
"subMetas": {
"p3": {
"ver": "1.0.4",
"uuid": "15171692-6cb7-462b-aca3-86891a8c425a",
"rawTextureUuid": "0a711ec1-92b8-4ff7-b0f5-feb00b6a2c24",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 23,
"trimY": 23,
"width": 104,
"height": 104,
"rawWidth": 150,
"rawHeight": 150,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "de7b6722-7804-402d-93f0-1eb866a83834",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 184,
"height": 184,
"platformSettings": {},
"subMetas": {
"voice_white": {
"ver": "1.0.4",
"uuid": "4a26b10f-d021-4bad-ac0e-f513daa05ae5",
"rawTextureUuid": "de7b6722-7804-402d-93f0-1eb866a83834",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 1,
"offsetY": 0,
"trimX": 12,
"trimY": 11,
"width": 162,
"height": 162,
"rawWidth": 184,
"rawHeight": 184,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
This diff is collapsed.
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