Commit b739e1fc authored by 李维's avatar 李维

完成语音评测页面

parent f8b65a0e
...@@ -4,25 +4,54 @@ ...@@ -4,25 +4,54 @@
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html // - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks: // Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html // - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
async function asyncPlayDragonBoneAnimation(node, animationName, time = 1, onFrameEvent = null) { async function asyncPlayDragonBoneAnimation(
node,
animationName,
time = 1,
onFrameEvent = null
) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
node.getComponent(dragonBones.ArmatureDisplay) node
.getComponent(dragonBones.ArmatureDisplay)
.once(dragonBones.EventObject.COMPLETE, () => { .once(dragonBones.EventObject.COMPLETE, () => {
resolve(null); resolve(null);
}); });
node.getComponent(dragonBones.ArmatureDisplay) node
.getComponent(dragonBones.ArmatureDisplay)
.on(dragonBones.EventObject.FRAME_EVENT, ({ name }) => { .on(dragonBones.EventObject.FRAME_EVENT, ({ name }) => {
if (onFrameEvent && typeof (onFrameEvent) == 'function') { if (onFrameEvent && typeof onFrameEvent == "function") {
onFrameEvent(name); onFrameEvent(name);
} }
}); });
node.getComponent(dragonBones.ArmatureDisplay) node
.getComponent(dragonBones.ArmatureDisplay)
.playAnimation(animationName, time); .playAnimation(animationName, time);
}); });
} }
function playAudioByUrl(audio_url, cb = null) {
return new Promise((resolve, reject) => {
if (audio_url) {
cc.assetManager.loadRemote(audio_url, (err, audioClip) => {
const audioId = cc.audioEngine.play(audioClip, false, 0.8);
resolve(audioId);
if (cb) {
cc.audioEngine.setFinishCallback(audioId, () => {
cb();
});
}
});
} else {
resolve(0);
if (cb) {
cb();
}
}
});
}
cc.Class({ cc.Class({
extends: cc.Component, extends: cc.Component,
...@@ -42,15 +71,20 @@ cc.Class({ ...@@ -42,15 +71,20 @@ cc.Class({
// this._bar = value; // this._bar = value;
// } // }
// }, // },
audioBeforeTest: "",
recordWaitCount: 0,
}, },
// LIFE-CYCLE CALLBACKS: // LIFE-CYCLE CALLBACKS:
// onLoad () {}, // onLoad () {},
start () { start() {},
init(audio_url) {
this.audioBeforeTest = audio_url;
}, },
showVoice(node, testLetter) { showVoice(node, testLetter) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
let voice = this.node; let voice = this.node;
...@@ -78,167 +112,169 @@ cc.Class({ ...@@ -78,167 +112,169 @@ cc.Class({
cloneNode.y = 0; cloneNode.y = 0;
img.addChild(cloneNode); img.addChild(cloneNode);
let progressBar = progress.getComponent(cc.ProgressBar) let progressBar = progress.getComponent(cc.ProgressBar);
progressBar.progress = 1; progressBar.progress = 1;
let url = this.recordWaitCount == 0 ? this.data.recordWait : ""; let url = this.recordWaitCount == 0 ? this.audioBeforeTest : "";
// this.playAudioByUrl(url, () => {
let cat = cc.find("cat", catBase); let cat = cc.find("cat", catBase);
asyncPlayDragonBoneAnimation(cat, "begin", 0);
playAudioByUrl(url, () => {
asyncPlayDragonBoneAnimation(cat, "record", 0); asyncPlayDragonBoneAnimation(cat, "record", 0);
cc.tween(progressBar).delay(1).to(3, { progress: 0 }).call(() => { cc.tween(progressBar)
}).start(); .delay(1)
.to(3, { progress: 0 })
.call(() => {})
.start();
console.log('startTest->' + testLetter); console.log("startTest->" + testLetter);
window.courseware && window.courseware.startTest(testLetter); //开始录音 window.courseware && window.courseware.startTest(testLetter); //开始录音
setTimeout(async () => { setTimeout(async () => {
if (!window.courseware) { if (!window.courseware) {
let testData = { let testData = {
"dtLastResponse": "2021-09-17 13:36:26:109", dtLastResponse: "2021-09-17 13:36:26:109",
"refText": "I haven't found anything out about him yet.", refText: "I haven't found anything out about him yet.",
"recordId": "6144295213f0a2200000ed93", recordId: "6144295213f0a2200000ed93",
"eof": 1, eof: 1,
"result": { result: {
"pronunciation": 25, pronunciation: 25,
"resource_version": "3.1.0", resource_version: "3.1.0",
"fluency": 60, fluency: 60,
"rhythm": 90, rhythm: 90,
"kernel_version": "5.2.4", kernel_version: "5.2.4",
"overall": 80,//25 overall: 80, //25
"integrity": 100, integrity: 100,
"duration": "6.779", duration: "6.779",
"rear_tone": "fall", rear_tone: "fall",
"speed": 96, speed: 96,
"words": [ words: [
{ {
"phonemes": [ phonemes: [
{ {
"phoneme": "w", phoneme: "w",
"pronunciation": 55, pronunciation: 55,
"span": { span: {
"end": 95, end: 95,
"start": 88 start: 88,
} },
}, },
{ {
"phoneme": "ɛ", phoneme: "ɛ",
"pronunciation": 100, pronunciation: 100,
"span": { span: {
"end": 107, end: 107,
"start": 95 start: 95,
} },
}, },
{ {
"phoneme": "r", phoneme: "r",
"pronunciation": 99, pronunciation: 99,
"span": { span: {
"end": 123, end: 123,
"start": 107 start: 107,
} },
} },
], ],
"phonics": [ phonics: [
{ {
"overall": 85, overall: 85,
"phoneme": [ phoneme: ["w", "ɛ", "r"],
"w", spell: "Where",
"ɛ", },
"r"
],
"spell": "Where"
}
], ],
"scores": { scores: {
"overall": 80, overall: 80,
"pronunciation": 92 pronunciation: 92,
},
span: {
end: 123,
start: 88,
}, },
"span": { word: "Where",
"end": 123,
"start": 88
}, },
"word": "Where"
}, {
"phonemes": [
{ {
"phoneme": "w", phonemes: [
"pronunciation": 55, {
"span": { phoneme: "w",
"end": 95, pronunciation: 55,
"start": 88 span: {
} end: 95,
start: 88,
},
}, },
{ {
"phoneme": "ɛ", phoneme: "ɛ",
"pronunciation": 100, pronunciation: 100,
"span": { span: {
"end": 107, end: 107,
"start": 95 start: 95,
} },
}, },
{ {
"phoneme": "r", phoneme: "r",
"pronunciation": 99, pronunciation: 99,
"span": { span: {
"end": 123, end: 123,
"start": 107 start: 107,
} },
} },
], ],
"phonics": [ phonics: [
{ {
"overall": 85, overall: 85,
"phoneme": [ phoneme: ["w", "ɛ", "r"],
"w", spell: "Where",
"ɛ", },
"r"
],
"spell": "Where"
}
], ],
"scores": { scores: {
"overall": 10, overall: 10,
"pronunciation": 92 pronunciation: 92,
}, },
"span": { span: {
"end": 123, end: 123,
"start": 88 start: 88,
}, },
"word": "Where" word: "Where",
}
]
}, },
"tokenId": "6144295408558b08dd000001", ],
"applicationId": "154838659000009e" },
} tokenId: "6144295408558b08dd000001",
applicationId: "154838659000009e",
};
this.recordWaitCount++; this.recordWaitCount++;
if (this.recrodEnd(testData)) { if (this.recrodEnd(testData)) {
// this.playLocalAudio("正确"); this.playLocalAudio("right");
asyncPlayDragonBoneAnimation(cat, "right", 1);
await this.showVoiceGood(); await this.showVoiceGood();
this.hideVoice(); this.hideVoice();
return resolve(true) return resolve(true);
} else { } else {
// this.playLocalAudio("错误弹回"); this.playLocalAudio("wrong");
asyncPlayDragonBoneAnimation(cat, "wrong", 1);
await this.showVoiceTry(); await this.showVoiceTry();
this.hideVoice(); this.hideVoice();
return resolve(false); return resolve(false);
} }
} }
// await pg.time.delay(5); // await pg.time.delay(5);
window.courseware && window.courseware.stopTest(async (data) => { window.courseware &&
window.courseware.stopTest(async (data) => {
this.recordWaitCount++; this.recordWaitCount++;
data = JSON.parse(data); data = JSON.parse(data);
if (this.recrodEnd(data)) { if (this.recrodEnd(data)) {
// this.playLocalAudio("正确"); this.playLocalAudio("right");
asyncPlayDragonBoneAnimation(cat, "right", 1);
await this.showVoiceGood(); await this.showVoiceGood();
this.hideVoice(); this.hideVoice();
return resolve(true) return resolve(true);
} else { } else {
// this.playLocalAudio("错误弹回"); this.playLocalAudio("错误弹回");
asyncPlayDragonBoneAnimation(cat, "wrong", 1);
await this.showVoiceTry(); await this.showVoiceTry();
this.hideVoice(); this.hideVoice();
return resolve(false); return resolve(false);
} }
}); //结束录音 }); //结束录音
}, 4000); }, 4000);
// }) });
}); });
}, },
...@@ -251,14 +287,11 @@ cc.Class({ ...@@ -251,14 +287,11 @@ cc.Class({
let imgTry = voice.getChildByName("try"); let imgTry = voice.getChildByName("try");
imgLight.active = true; imgLight.active = true;
cc.Tween.stopAllByTarget(imgLight); cc.Tween.stopAllByTarget(imgLight);
cc.tween(imgLight) cc.tween(imgLight).by(3, { angle: 360 }).repeatForever().start();
.by(3, { angle: 360 })
.repeatForever()
.start();
imgGood.active = true; imgGood.active = true;
imgTry.active = false; imgTry.active = false;
setTimeout(() => { setTimeout(() => {
resolve(''); resolve("");
}, 2000); }, 2000);
}); });
}, },
...@@ -272,14 +305,11 @@ cc.Class({ ...@@ -272,14 +305,11 @@ cc.Class({
let imgTry = voice.getChildByName("try"); let imgTry = voice.getChildByName("try");
imgLight.active = true; imgLight.active = true;
cc.Tween.stopAllByTarget(imgLight); cc.Tween.stopAllByTarget(imgLight);
cc.tween(imgLight) cc.tween(imgLight).by(3, { angle: 360 }).repeatForever().start();
.by(3, { angle: 360 })
.repeatForever()
.start();
imgGood.active = false; imgGood.active = false;
imgTry.active = true; imgTry.active = true;
setTimeout(() => { setTimeout(() => {
resolve(''); resolve("");
}, 2000); }, 2000);
}); });
}, },
...@@ -302,7 +332,7 @@ cc.Class({ ...@@ -302,7 +332,7 @@ cc.Class({
if (!sentences) return true; if (!sentences) return true;
for (let i = 0; i < sentences.length; i++) { for (let i = 0; i < sentences.length; i++) {
const details = sentences[i].details; const details = sentences[i].details;
const isSuccess = details.some(item => item.overall <= 40); const isSuccess = details.some((item) => item.overall <= 40);
if (isSuccess) return false; if (isSuccess) return false;
} }
return true; return true;
...@@ -311,6 +341,18 @@ cc.Class({ ...@@ -311,6 +341,18 @@ cc.Class({
hideVoice() { hideVoice() {
let voice = this.node; let voice = this.node;
voice.active = false; voice.active = false;
},
playLocalAudio(audioName) {
const audio = cc
.find(`audioClips/${audioName}`, this.node)
.getComponent(cc.AudioSource);
return new Promise((resolve, reject) => {
const id = cc.audioEngine.playEffect(audio.clip, false);
cc.audioEngine.setFinishCallback(id, () => {
resolve(id);
});
});
} }
// update (dt) {}, // update (dt) {},
......
...@@ -40,19 +40,22 @@ ...@@ -40,19 +40,22 @@
}, },
{ {
"__id__": 33 "__id__": 33
},
{
"__id__": 36
} }
], ],
"_active": true, "_active": false,
"_components": [ "_components": [
{ {
"__id__": 36 "__id__": 44
}, },
{ {
"__id__": 37 "__id__": 45
} }
], ],
"_prefab": { "_prefab": {
"__id__": 38 "__id__": 46
}, },
"_opacity": 255, "_opacity": 255,
"_color": { "_color": {
...@@ -1342,6 +1345,272 @@ ...@@ -1342,6 +1345,272 @@
"fileId": "c8TTnwgvpL2Kb1J1NCiHC8", "fileId": "c8TTnwgvpL2Kb1J1NCiHC8",
"sync": false "sync": false
}, },
{
"__type__": "cc.Node",
"_name": "audioClips",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [
{
"__id__": 37
},
{
"__id__": 40
}
],
"_active": true,
"_components": [],
"_prefab": {
"__id__": 43
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 0,
"height": 0
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
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": ""
},
{
"__type__": "cc.Node",
"_name": "right",
"_objFlags": 0,
"_parent": {
"__id__": 36
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 38
}
],
"_prefab": {
"__id__": 39
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 0,
"height": 0
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
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": ""
},
{
"__type__": "cc.AudioSource",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 37
},
"_enabled": true,
"_clip": {
"__uuid__": "9ab937ea-56b2-433a-8bf2-fc5db40f33d6"
},
"_volume": 1,
"_mute": false,
"_loop": false,
"_firstlyEnabled": true,
"playOnLoad": false,
"preload": false,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "87e8bdef-072f-4642-b630-352bb34d47b4"
},
"fileId": "b72HtDZt5D1JFSlkV3dHvr",
"sync": false
},
{
"__type__": "cc.Node",
"_name": "wrong",
"_objFlags": 0,
"_parent": {
"__id__": 36
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 41
}
],
"_prefab": {
"__id__": 42
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 0,
"height": 0
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
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": ""
},
{
"__type__": "cc.AudioSource",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 40
},
"_enabled": true,
"_clip": {
"__uuid__": "2ca571b6-6cc3-4b8f-830e-e9dd662c0b6c"
},
"_volume": 1,
"_mute": false,
"_loop": false,
"_firstlyEnabled": true,
"playOnLoad": false,
"preload": false,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "87e8bdef-072f-4642-b630-352bb34d47b4"
},
"fileId": "0chKulT+1NHLcNjfZBplCI",
"sync": false
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "87e8bdef-072f-4642-b630-352bb34d47b4"
},
"fileId": "dessiBBVFGHYtjCtBgRQeZ",
"sync": false
},
{ {
"__type__": "cc.Widget", "__type__": "cc.Widget",
"_name": "", "_name": "",
...@@ -1377,6 +1646,8 @@ ...@@ -1377,6 +1646,8 @@
"__id__": 1 "__id__": 1
}, },
"_enabled": true, "_enabled": true,
"audioBeforeTest": "",
"recordWaitCount": 0,
"_id": "" "_id": ""
}, },
{ {
......
{
"ver": "1.1.2",
"uuid": "d5d7295b-e125-4e5f-b27f-fc93795c8e53",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "9ab937ea-56b2-433a-8bf2-fc5db40f33d6",
"downloadMode": 0,
"duration": 0.45102,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "2ca571b6-6cc3-4b8f-830e-e9dd662c0b6c",
"downloadMode": 0,
"duration": 0.6818,
"subMetas": {}
}
\ No newline at end of file
...@@ -28,8 +28,8 @@ ...@@ -28,8 +28,8 @@
"rawHeight": 51, "rawHeight": 51,
"borderTop": 0, "borderTop": 0,
"borderBottom": 0, "borderBottom": 0,
"borderLeft": 0, "borderLeft": 38,
"borderRight": 0, "borderRight": 16,
"subMetas": {} "subMetas": {}
} }
} }
......
...@@ -96,25 +96,25 @@ ...@@ -96,25 +96,25 @@
"__id__": 217 "__id__": 217
}, },
{ {
"__id__": 255 "__id__": 263
}, },
{ {
"__id__": 256 "__id__": 264
}, },
{ {
"__id__": 257 "__id__": 265
} }
], ],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 265 "__id__": 273
}, },
{ {
"__id__": 266 "__id__": 274
}, },
{ {
"__id__": 267 "__id__": 275
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -10847,19 +10847,22 @@ ...@@ -10847,19 +10847,22 @@
}, },
{ {
"__id__": 249 "__id__": 249
},
{
"__id__": 252
} }
], ],
"_active": false, "_active": false,
"_components": [ "_components": [
{ {
"__id__": 252 "__id__": 260
}, },
{ {
"__id__": 253 "__id__": 261
} }
], ],
"_prefab": { "_prefab": {
"__id__": 254 "__id__": 262
}, },
"_opacity": 255, "_opacity": 255,
"_color": { "_color": {
...@@ -10883,8 +10886,8 @@ ...@@ -10883,8 +10886,8 @@
"__type__": "TypedArray", "__type__": "TypedArray",
"ctor": "Float64Array", "ctor": "Float64Array",
"array": [ "array": [
0, 1280,
0, 960,
0, 0,
0, 0,
0, 0,
...@@ -10906,7 +10909,7 @@ ...@@ -10906,7 +10909,7 @@
"_is3DNode": false, "_is3DNode": false,
"_groupIndex": 0, "_groupIndex": 0,
"groupIndex": 0, "groupIndex": 0,
"_id": "79NB9B0J1FfauSvPDUXMbh" "_id": "75T40zECtOHZ/PNIbc2zBZ"
}, },
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
...@@ -10973,7 +10976,7 @@ ...@@ -10973,7 +10976,7 @@
"_is3DNode": false, "_is3DNode": false,
"_groupIndex": 0, "_groupIndex": 0,
"groupIndex": 0, "groupIndex": 0,
"_id": "25eIyBPg5KTKYeW1jVd5hq" "_id": "ddzAmTzuVITaOoE1N7BCZH"
}, },
{ {
"__type__": "cc.Sprite", "__type__": "cc.Sprite",
...@@ -11005,7 +11008,7 @@ ...@@ -11005,7 +11008,7 @@
"_fillRange": 0, "_fillRange": 0,
"_isTrimmedMode": true, "_isTrimmedMode": true,
"_atlas": null, "_atlas": null,
"_id": "d3niGuB7hAZ4BSc8vWkjTl" "_id": "2fRl7/ZLlJSarpHEremvst"
}, },
{ {
"__type__": "cc.Widget", "__type__": "cc.Widget",
...@@ -11032,7 +11035,7 @@ ...@@ -11032,7 +11035,7 @@
"_isAbsVerticalCenter": true, "_isAbsVerticalCenter": true,
"_originalWidth": 50000, "_originalWidth": 50000,
"_originalHeight": 50000, "_originalHeight": 50000,
"_id": "59XcWTDXVB95RS6FgQqh+i" "_id": "a5spwm7L9JeqAiDFb82ZOQ"
}, },
{ {
"__type__": "cc.PrefabInfo", "__type__": "cc.PrefabInfo",
...@@ -11107,7 +11110,7 @@ ...@@ -11107,7 +11110,7 @@
"_is3DNode": false, "_is3DNode": false,
"_groupIndex": 0, "_groupIndex": 0,
"groupIndex": 0, "groupIndex": 0,
"_id": "f93KPVOY9CZrOTBk8Bve7h" "_id": "29v0F+8INF4K5Yi1ml40nK"
}, },
{ {
"__type__": "cc.Sprite", "__type__": "cc.Sprite",
...@@ -11139,7 +11142,7 @@ ...@@ -11139,7 +11142,7 @@
"_fillRange": 0, "_fillRange": 0,
"_isTrimmedMode": true, "_isTrimmedMode": true,
"_atlas": null, "_atlas": null,
"_id": "24r1x8rhxI/7yqShCECNCc" "_id": "71925cD3xDRosrohdHWJ7O"
}, },
{ {
"__type__": "cc.PrefabInfo", "__type__": "cc.PrefabInfo",
...@@ -11221,7 +11224,7 @@ ...@@ -11221,7 +11224,7 @@
"_is3DNode": false, "_is3DNode": false,
"_groupIndex": 0, "_groupIndex": 0,
"groupIndex": 0, "groupIndex": 0,
"_id": "6elb8plVtISIgk6DNuRClg" "_id": "794qnVDp5Li5VDUv2YfzFq"
}, },
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
...@@ -11285,7 +11288,7 @@ ...@@ -11285,7 +11288,7 @@
"_is3DNode": false, "_is3DNode": false,
"_groupIndex": 0, "_groupIndex": 0,
"groupIndex": 0, "groupIndex": 0,
"_id": "f4S9uq0mdKeIxAP84PTlnK" "_id": "d2lE+bhI5Nt7ll6nwKxSXm"
}, },
{ {
"__type__": "dragonBones.ArmatureDisplay", "__type__": "dragonBones.ArmatureDisplay",
...@@ -11325,7 +11328,7 @@ ...@@ -11325,7 +11328,7 @@
"_N$timeScale": 1, "_N$timeScale": 1,
"_N$debugBones": false, "_N$debugBones": false,
"_N$enableBatch": false, "_N$enableBatch": false,
"_id": "d8jZh7qctI4Y4H8xmkly60" "_id": "eaHuu4h7BFdJsPszHnMCWC"
}, },
{ {
"__type__": "cc.PrefabInfo", "__type__": "cc.PrefabInfo",
...@@ -11400,7 +11403,7 @@ ...@@ -11400,7 +11403,7 @@
"_is3DNode": false, "_is3DNode": false,
"_groupIndex": 0, "_groupIndex": 0,
"groupIndex": 0, "groupIndex": 0,
"_id": "b97wBzAB5Pk4L2olvLd2WX" "_id": "d7BdU+23NFlq0gus9fb6Rq"
}, },
{ {
"__type__": "cc.Button", "__type__": "cc.Button",
...@@ -11468,7 +11471,7 @@ ...@@ -11468,7 +11471,7 @@
"hoverSprite": null, "hoverSprite": null,
"_N$disabledSprite": null, "_N$disabledSprite": null,
"_N$target": null, "_N$target": null,
"_id": "d9Ji/J+eVHSLuGOKaX9toC" "_id": "fbQbgiOVNLnJVg64xhTeCs"
}, },
{ {
"__type__": "cc.PrefabInfo", "__type__": "cc.PrefabInfo",
...@@ -11506,7 +11509,7 @@ ...@@ -11506,7 +11509,7 @@
"_isAbsVerticalCenter": true, "_isAbsVerticalCenter": true,
"_originalWidth": 0, "_originalWidth": 0,
"_originalHeight": 0, "_originalHeight": 0,
"_id": "96D6C5Zy1LFJqgyqPFceqN" "_id": "b0PeZu5etOsKr93+sWOWPK"
}, },
{ {
"__type__": "cc.PrefabInfo", "__type__": "cc.PrefabInfo",
...@@ -11577,7 +11580,7 @@ ...@@ -11577,7 +11580,7 @@
"_is3DNode": false, "_is3DNode": false,
"_groupIndex": 0, "_groupIndex": 0,
"groupIndex": 0, "groupIndex": 0,
"_id": "37naXtTW5DNqWWbCt6ovxK" "_id": "d3Vofx3K9J5Ko1hQXoPY2Z"
}, },
{ {
"__type__": "cc.PrefabInfo", "__type__": "cc.PrefabInfo",
...@@ -11659,7 +11662,7 @@ ...@@ -11659,7 +11662,7 @@
"_is3DNode": false, "_is3DNode": false,
"_groupIndex": 0, "_groupIndex": 0,
"groupIndex": 0, "groupIndex": 0,
"_id": "c06Ofer4xGT5nReH61vg4R" "_id": "8258XoFCJG4oT7vFhaLNDC"
}, },
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
...@@ -11723,7 +11726,7 @@ ...@@ -11723,7 +11726,7 @@
"_is3DNode": false, "_is3DNode": false,
"_groupIndex": 0, "_groupIndex": 0,
"groupIndex": 0, "groupIndex": 0,
"_id": "72BPWdVsBFJ6wOcBGv7ZF1" "_id": "40lesAfrZGQLCSYqjAnS/N"
}, },
{ {
"__type__": "cc.Sprite", "__type__": "cc.Sprite",
...@@ -11755,7 +11758,7 @@ ...@@ -11755,7 +11758,7 @@
"_fillRange": 0, "_fillRange": 0,
"_isTrimmedMode": true, "_isTrimmedMode": true,
"_atlas": null, "_atlas": null,
"_id": "efNSA72WZM0aHS0MzOWcxj" "_id": "62OI4sCt9LhYPvxdhYlAfk"
}, },
{ {
"__type__": "cc.PrefabInfo", "__type__": "cc.PrefabInfo",
...@@ -11798,7 +11801,7 @@ ...@@ -11798,7 +11801,7 @@
"_fillRange": 0, "_fillRange": 0,
"_isTrimmedMode": true, "_isTrimmedMode": true,
"_atlas": null, "_atlas": null,
"_id": "43SBOBZsNIp6oQaK5gRajw" "_id": "68wU0rYslCcpa1ajuz+3b1"
}, },
{ {
"__type__": "cc.ProgressBar", "__type__": "cc.ProgressBar",
...@@ -11815,7 +11818,7 @@ ...@@ -11815,7 +11818,7 @@
"_N$mode": 0, "_N$mode": 0,
"_N$progress": 1, "_N$progress": 1,
"_N$reverse": false, "_N$reverse": false,
"_id": "85Ehaed7ZGqbFRo5psxOKm" "_id": "dctEEwOqNIDYbNBqclw8jK"
}, },
{ {
"__type__": "cc.PrefabInfo", "__type__": "cc.PrefabInfo",
...@@ -11890,7 +11893,7 @@ ...@@ -11890,7 +11893,7 @@
"_is3DNode": false, "_is3DNode": false,
"_groupIndex": 0, "_groupIndex": 0,
"groupIndex": 0, "groupIndex": 0,
"_id": "35OlO/V6NJpJRA8ui8RcXy" "_id": "47p3W1uA5FY6svtCMOxpu8"
}, },
{ {
"__type__": "cc.Sprite", "__type__": "cc.Sprite",
...@@ -11922,7 +11925,7 @@ ...@@ -11922,7 +11925,7 @@
"_fillRange": 0, "_fillRange": 0,
"_isTrimmedMode": true, "_isTrimmedMode": true,
"_atlas": null, "_atlas": null,
"_id": "0cm8SN1S9GOJKWi3DCrlcv" "_id": "a2POaVqS1LE5wRVy+3zsYN"
}, },
{ {
"__type__": "cc.PrefabInfo", "__type__": "cc.PrefabInfo",
...@@ -11997,7 +12000,7 @@ ...@@ -11997,7 +12000,7 @@
"_is3DNode": false, "_is3DNode": false,
"_groupIndex": 0, "_groupIndex": 0,
"groupIndex": 0, "groupIndex": 0,
"_id": "deMplk1T5PeqUjlShlc1/7" "_id": "7dxPpEXjlEvb3csggtDs6R"
}, },
{ {
"__type__": "cc.Sprite", "__type__": "cc.Sprite",
...@@ -12029,7 +12032,7 @@ ...@@ -12029,7 +12032,7 @@
"_fillRange": 0, "_fillRange": 0,
"_isTrimmedMode": true, "_isTrimmedMode": true,
"_atlas": null, "_atlas": null,
"_id": "31WxfUs6tMv4flNn2WhkGX" "_id": "8fQkQ+22JLnYP+7gxO7M7h"
}, },
{ {
"__type__": "cc.PrefabInfo", "__type__": "cc.PrefabInfo",
...@@ -12104,7 +12107,7 @@ ...@@ -12104,7 +12107,7 @@
"_is3DNode": false, "_is3DNode": false,
"_groupIndex": 0, "_groupIndex": 0,
"groupIndex": 0, "groupIndex": 0,
"_id": "51v7JUPkpKZoy1EdfwK1Qx" "_id": "cfeNuCAvxOOrvcwNzWAKxH"
}, },
{ {
"__type__": "cc.Sprite", "__type__": "cc.Sprite",
...@@ -12136,7 +12139,7 @@ ...@@ -12136,7 +12139,7 @@
"_fillRange": 0, "_fillRange": 0,
"_isTrimmedMode": true, "_isTrimmedMode": true,
"_atlas": null, "_atlas": null,
"_id": "6bXtyznwtAnrgnfTI7jks/" "_id": "9c66G9YbdJc5LfqNu2no4R"
}, },
{ {
"__type__": "cc.PrefabInfo", "__type__": "cc.PrefabInfo",
...@@ -12149,6 +12152,272 @@ ...@@ -12149,6 +12152,272 @@
"fileId": "c8TTnwgvpL2Kb1J1NCiHC8", "fileId": "c8TTnwgvpL2Kb1J1NCiHC8",
"sync": false "sync": false
}, },
{
"__type__": "cc.Node",
"_name": "audioClips",
"_objFlags": 0,
"_parent": {
"__id__": 217
},
"_children": [
{
"__id__": 253
},
{
"__id__": 256
}
],
"_active": true,
"_components": [],
"_prefab": {
"__id__": 259
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 0,
"height": 0
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
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": "61axejzhFMYoPBgTjg0OML"
},
{
"__type__": "cc.Node",
"_name": "right",
"_objFlags": 0,
"_parent": {
"__id__": 252
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 254
}
],
"_prefab": {
"__id__": 255
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 0,
"height": 0
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
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": "fdPwq5iBVCMol4N6uZeM8Y"
},
{
"__type__": "cc.AudioSource",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 253
},
"_enabled": true,
"_clip": {
"__uuid__": "9ab937ea-56b2-433a-8bf2-fc5db40f33d6"
},
"_volume": 1,
"_mute": false,
"_loop": false,
"_firstlyEnabled": true,
"playOnLoad": false,
"preload": false,
"_id": "d1x8UxVXhMJZ+rZTpl7iq1"
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 217
},
"asset": {
"__uuid__": "87e8bdef-072f-4642-b630-352bb34d47b4"
},
"fileId": "b72HtDZt5D1JFSlkV3dHvr",
"sync": false
},
{
"__type__": "cc.Node",
"_name": "wrong",
"_objFlags": 0,
"_parent": {
"__id__": 252
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 257
}
],
"_prefab": {
"__id__": 258
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 0,
"height": 0
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
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": "860SZvIfJKeL/0gjAiy4lQ"
},
{
"__type__": "cc.AudioSource",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 256
},
"_enabled": true,
"_clip": {
"__uuid__": "2ca571b6-6cc3-4b8f-830e-e9dd662c0b6c"
},
"_volume": 1,
"_mute": false,
"_loop": false,
"_firstlyEnabled": true,
"playOnLoad": false,
"preload": false,
"_id": "9cuxz0FadH0YAP1NJk463P"
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 217
},
"asset": {
"__uuid__": "87e8bdef-072f-4642-b630-352bb34d47b4"
},
"fileId": "0chKulT+1NHLcNjfZBplCI",
"sync": false
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 217
},
"asset": {
"__uuid__": "87e8bdef-072f-4642-b630-352bb34d47b4"
},
"fileId": "dessiBBVFGHYtjCtBgRQeZ",
"sync": false
},
{ {
"__type__": "cc.Widget", "__type__": "cc.Widget",
"_name": "", "_name": "",
...@@ -12174,7 +12443,7 @@ ...@@ -12174,7 +12443,7 @@
"_isAbsVerticalCenter": true, "_isAbsVerticalCenter": true,
"_originalWidth": 0, "_originalWidth": 0,
"_originalHeight": 0, "_originalHeight": 0,
"_id": "f5JGE+TeFJ5oPBAawSIokG" "_id": "5awcLiOtZM9o4KbIW9/h0L"
}, },
{ {
"__type__": "16155YRBRBLL4FPRlTZRpiI", "__type__": "16155YRBRBLL4FPRlTZRpiI",
...@@ -12184,7 +12453,9 @@ ...@@ -12184,7 +12453,9 @@
"__id__": 217 "__id__": 217
}, },
"_enabled": true, "_enabled": true,
"_id": "8dfkVpHmxCl5/dY7sHIxjD" "audioBeforeTest": "",
"recordWaitCount": 0,
"_id": "3fY+V+UrRMDbcbChKnthRF"
}, },
{ {
"__type__": "cc.PrefabInfo", "__type__": "cc.PrefabInfo",
...@@ -12322,13 +12593,13 @@ ...@@ -12322,13 +12593,13 @@
}, },
"_children": [ "_children": [
{ {
"__id__": 258 "__id__": 266
}, },
{ {
"__id__": 261 "__id__": 269
}, },
{ {
"__id__": 262 "__id__": 270
} }
], ],
"_active": false, "_active": false,
...@@ -12386,11 +12657,11 @@ ...@@ -12386,11 +12657,11 @@
"_name": "font", "_name": "font",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 257 "__id__": 265
}, },
"_children": [ "_children": [
{ {
"__id__": 259 "__id__": 267
} }
], ],
"_active": true, "_active": true,
...@@ -12448,13 +12719,13 @@ ...@@ -12448,13 +12719,13 @@
"_name": "BRLNSDB", "_name": "BRLNSDB",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 258 "__id__": 266
}, },
"_children": [], "_children": [],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 260 "__id__": 268
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -12510,7 +12781,7 @@ ...@@ -12510,7 +12781,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 259 "__id__": 267
}, },
"_enabled": true, "_enabled": true,
"_materials": [], "_materials": [],
...@@ -12541,7 +12812,7 @@ ...@@ -12541,7 +12812,7 @@
"_name": "img", "_name": "img",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 257 "__id__": 265
}, },
"_children": [], "_children": [],
"_active": true, "_active": true,
...@@ -12599,11 +12870,11 @@ ...@@ -12599,11 +12870,11 @@
"_name": "audio", "_name": "audio",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 257 "__id__": 265
}, },
"_children": [ "_children": [
{ {
"__id__": 263 "__id__": 271
} }
], ],
"_active": true, "_active": true,
...@@ -12661,13 +12932,13 @@ ...@@ -12661,13 +12932,13 @@
"_name": "btn", "_name": "btn",
"_objFlags": 512, "_objFlags": 512,
"_parent": { "_parent": {
"__id__": 262 "__id__": 270
}, },
"_children": [], "_children": [],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 264 "__id__": 272
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -12723,7 +12994,7 @@ ...@@ -12723,7 +12994,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 263 "__id__": 271
}, },
"_enabled": true, "_enabled": true,
"_clip": { "_clip": {
......
...@@ -27,6 +27,7 @@ const MSG_PLAYER_TO_HOME = "msg_player_to_home"; ...@@ -27,6 +27,7 @@ const MSG_PLAYER_TO_HOME = "msg_player_to_home";
const MSG_PROFIX_END = "__END__"; const MSG_PROFIX_END = "__END__";
const DEBUG = true; const DEBUG = true;
const TOTAL_SCORE = 42; // 总分 - 双方分数之和等于 TOTAL_SCORE const TOTAL_SCORE = 42; // 总分 - 双方分数之和等于 TOTAL_SCORE
const AI_SUCCESS_RATE = 0.85; // ai评测成功率
@ccclass @ccclass
export default class SceneComponent extends MyCocosSceneComponent { export default class SceneComponent extends MyCocosSceneComponent {
...@@ -152,6 +153,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -152,6 +153,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.initLoadingLayer(); this.initLoadingLayer();
this.initOfflineLayer(); this.initOfflineLayer();
this.initPronunciationTestLayer(); this.initPronunciationTestLayer();
this.initCoolCat();
this.initTurntable(); this.initTurntable();
this.initGemstone(); this.initGemstone();
this.initScore(); this.initScore();
...@@ -210,6 +212,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -210,6 +212,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
initPronunciationTestLayer() { initPronunciationTestLayer() {
const loadingLayerBase = cc.find("Canvas/PronunciationTestLayer"); const loadingLayerBase = cc.find("Canvas/PronunciationTestLayer");
this.pronunciationTestLayer = loadingLayerBase.getComponent("PronunciationTestLayer"); this.pronunciationTestLayer = loadingLayerBase.getComponent("PronunciationTestLayer");
this.pronunciationTestLayer.init("http://staging-teach.cdn.ireadabc.com/31952573236dd316a8ee1672d1614a1c.mp3")
} }
redPlayerNode = null; redPlayerNode = null;
...@@ -238,6 +241,12 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -238,6 +241,12 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.treeNode = cc.find("Canvas/center_map/tree/stand"); this.treeNode = cc.find("Canvas/center_map/tree/stand");
} }
// 初始化酷猫
coolCat = null;
initCoolCat() {
this.coolCat = cc.find("Canvas/coolcatLand/coolcat");
}
// 小人上树 // 小人上树
playerToTree(playerNode) { playerToTree(playerNode) {
const wordPos = this.treeNode.convertToWorldSpaceAR(cc.v2(0, 0)) const wordPos = this.treeNode.convertToWorldSpaceAR(cc.v2(0, 0))
...@@ -700,7 +709,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -700,7 +709,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
if(isAi) { if(isAi) {
setTimeout(() => { setTimeout(() => {
console.log("语音评测结束") console.log("语音评测结束")
if(Math.random() > 1) { if(Math.random() > AI_SUCCESS_RATE) {
console.log("评测失败,后退") console.log("评测失败,后退")
// 后退 // 后退
this.runEvent(MSG_PLAYER_TO_HOME, {success: false, gemIndex: param.index}); this.runEvent(MSG_PLAYER_TO_HOME, {success: false, gemIndex: param.index});
...@@ -711,7 +720,9 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -711,7 +720,9 @@ export default class SceneComponent extends MyCocosSceneComponent {
} }
}, DEBUG?10:2000); }, DEBUG?10:2000);
} else { } else {
this.coolCat.active = false;
this.pronunciationTestLayer.showVoice(this.gemstonesAll[param.index], this.gemstonesAll[param.index].__letter).then(res=>{ this.pronunciationTestLayer.showVoice(this.gemstonesAll[param.index], this.gemstonesAll[param.index].__letter).then(res=>{
this.coolCat.active = true;
this.runEvent(MSG_PLAYER_TO_HOME, {success: res, gemIndex: param.index}); this.runEvent(MSG_PLAYER_TO_HOME, {success: res, gemIndex: param.index});
}) })
} }
......
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