Commit b739e1fc authored by 李维's avatar 李维

完成语音评测页面

parent f8b65a0e
......@@ -4,314 +4,356 @@
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - 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) => {
node.getComponent(dragonBones.ArmatureDisplay)
node
.getComponent(dragonBones.ArmatureDisplay)
.once(dragonBones.EventObject.COMPLETE, () => {
resolve(null);
});
node.getComponent(dragonBones.ArmatureDisplay)
node
.getComponent(dragonBones.ArmatureDisplay)
.on(dragonBones.EventObject.FRAME_EVENT, ({ name }) => {
if (onFrameEvent && typeof (onFrameEvent) == 'function') {
if (onFrameEvent && typeof onFrameEvent == "function") {
onFrameEvent(name);
}
});
node.getComponent(dragonBones.ArmatureDisplay)
node
.getComponent(dragonBones.ArmatureDisplay)
.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({
extends: cc.Component,
extends: cc.Component,
properties: {
// foo: {
// // ATTRIBUTES:
// default: null, // The default value will be used only when the component attaching
// // to a node for the first time
// type: cc.SpriteFrame, // optional, default is typeof default
// serializable: true, // optional, default is true
// },
// bar: {
// get () {
// return this._bar;
// },
// set (value) {
// this._bar = value;
// }
// },
audioBeforeTest: "",
recordWaitCount: 0,
},
properties: {
// foo: {
// // ATTRIBUTES:
// default: null, // The default value will be used only when the component attaching
// // to a node for the first time
// type: cc.SpriteFrame, // optional, default is typeof default
// serializable: true, // optional, default is true
// },
// bar: {
// get () {
// return this._bar;
// },
// set (value) {
// this._bar = value;
// }
// },
},
// LIFE-CYCLE CALLBACKS:
// LIFE-CYCLE CALLBACKS:
// onLoad () {},
// onLoad () {},
start() {},
start () {
init(audio_url) {
this.audioBeforeTest = audio_url;
},
},
showVoice(node, testLetter) {
return new Promise((resolve, reject) => {
let voice = this.node;
voice.active = true;
let gray = voice.getChildByName("gray");
let catBase = voice.getChildByName("catBase");
let img = voice.getChildByName("img");
let progress = voice.getChildByName("progress");
let imgLight = voice.getChildByName("bg_light");
let imgGood = voice.getChildByName("good");
let imgTry = voice.getChildByName("try");
progress.active = true;
img.active = true;
imgLight.active = false;
imgGood.active = false;
imgTry.active = false;
catBase.active = true;
//img需要clone对应的节点塞进去。
img.removeAllChildren();
let cloneNode = cc.instantiate(node);
cloneNode.x = 0;
cloneNode.y = 0;
img.addChild(cloneNode);
let progressBar = progress.getComponent(cc.ProgressBar)
progressBar.progress = 1;
let url = this.recordWaitCount == 0 ? this.data.recordWait : "";
// this.playAudioByUrl(url, () => {
let cat = cc.find("cat", catBase);
asyncPlayDragonBoneAnimation(cat, "record", 0);
cc.tween(progressBar).delay(1).to(3, { progress: 0 }).call(() => {
}).start();
console.log('startTest->' + testLetter);
window.courseware && window.courseware.startTest(testLetter); //开始录音
setTimeout(async () => {
if (!window.courseware) {
let testData = {
"dtLastResponse": "2021-09-17 13:36:26:109",
"refText": "I haven't found anything out about him yet.",
"recordId": "6144295213f0a2200000ed93",
"eof": 1,
"result": {
"pronunciation": 25,
"resource_version": "3.1.0",
"fluency": 60,
"rhythm": 90,
"kernel_version": "5.2.4",
"overall": 80,//25
"integrity": 100,
"duration": "6.779",
"rear_tone": "fall",
"speed": 96,
"words": [
showVoice(node, testLetter) {
return new Promise((resolve, reject) => {
let voice = this.node;
voice.active = true;
let gray = voice.getChildByName("gray");
let catBase = voice.getChildByName("catBase");
let img = voice.getChildByName("img");
let progress = voice.getChildByName("progress");
let imgLight = voice.getChildByName("bg_light");
let imgGood = voice.getChildByName("good");
let imgTry = voice.getChildByName("try");
progress.active = true;
img.active = true;
imgLight.active = false;
imgGood.active = false;
imgTry.active = false;
catBase.active = true;
//img需要clone对应的节点塞进去。
img.removeAllChildren();
let cloneNode = cc.instantiate(node);
cloneNode.x = 0;
cloneNode.y = 0;
img.addChild(cloneNode);
let progressBar = progress.getComponent(cc.ProgressBar);
progressBar.progress = 1;
let url = this.recordWaitCount == 0 ? this.audioBeforeTest : "";
let cat = cc.find("cat", catBase);
asyncPlayDragonBoneAnimation(cat, "begin", 0);
playAudioByUrl(url, () => {
asyncPlayDragonBoneAnimation(cat, "record", 0);
cc.tween(progressBar)
.delay(1)
.to(3, { progress: 0 })
.call(() => {})
.start();
console.log("startTest->" + testLetter);
window.courseware && window.courseware.startTest(testLetter); //开始录音
setTimeout(async () => {
if (!window.courseware) {
let testData = {
dtLastResponse: "2021-09-17 13:36:26:109",
refText: "I haven't found anything out about him yet.",
recordId: "6144295213f0a2200000ed93",
eof: 1,
result: {
pronunciation: 25,
resource_version: "3.1.0",
fluency: 60,
rhythm: 90,
kernel_version: "5.2.4",
overall: 80, //25
integrity: 100,
duration: "6.779",
rear_tone: "fall",
speed: 96,
words: [
{
phonemes: [
{
phoneme: "w",
pronunciation: 55,
span: {
end: 95,
start: 88,
},
},
{
phoneme: "ɛ",
pronunciation: 100,
span: {
end: 107,
start: 95,
},
},
{
"phonemes": [
{
"phoneme": "w",
"pronunciation": 55,
"span": {
"end": 95,
"start": 88
}
},
{
"phoneme": "ɛ",
"pronunciation": 100,
"span": {
"end": 107,
"start": 95
}
},
{
"phoneme": "r",
"pronunciation": 99,
"span": {
"end": 123,
"start": 107
}
}
],
"phonics": [
{
"overall": 85,
"phoneme": [
"w",
"ɛ",
"r"
],
"spell": "Where"
}
],
"scores": {
"overall": 80,
"pronunciation": 92
phoneme: "r",
pronunciation: 99,
span: {
end: 123,
start: 107,
},
"span": {
"end": 123,
"start": 88
},
],
phonics: [
{
overall: 85,
phoneme: ["w", "ɛ", "r"],
spell: "Where",
},
],
scores: {
overall: 80,
pronunciation: 92,
},
span: {
end: 123,
start: 88,
},
word: "Where",
},
{
phonemes: [
{
phoneme: "w",
pronunciation: 55,
span: {
end: 95,
start: 88,
},
"word": "Where"
}, {
"phonemes": [
{
"phoneme": "w",
"pronunciation": 55,
"span": {
"end": 95,
"start": 88
}
},
{
"phoneme": "ɛ",
"pronunciation": 100,
"span": {
"end": 107,
"start": 95
}
},
{
"phoneme": "r",
"pronunciation": 99,
"span": {
"end": 123,
"start": 107
}
}
],
"phonics": [
{
"overall": 85,
"phoneme": [
"w",
"ɛ",
"r"
],
"spell": "Where"
}
],
"scores": {
"overall": 10,
"pronunciation": 92
},
{
phoneme: "ɛ",
pronunciation: 100,
span: {
end: 107,
start: 95,
},
"span": {
"end": 123,
"start": 88
},
{
phoneme: "r",
pronunciation: 99,
span: {
end: 123,
start: 107,
},
"word": "Where"
}
]
},
],
phonics: [
{
overall: 85,
phoneme: ["w", "ɛ", "r"],
spell: "Where",
},
],
scores: {
overall: 10,
pronunciation: 92,
},
span: {
end: 123,
start: 88,
},
word: "Where",
},
"tokenId": "6144295408558b08dd000001",
"applicationId": "154838659000009e"
}
this.recordWaitCount++;
if (this.recrodEnd(testData)) {
// this.playLocalAudio("正确");
await this.showVoiceGood();
this.hideVoice();
return resolve(true)
} else {
// this.playLocalAudio("错误弹回");
await this.showVoiceTry();
this.hideVoice();
return resolve(false);
}
],
},
tokenId: "6144295408558b08dd000001",
applicationId: "154838659000009e",
};
this.recordWaitCount++;
if (this.recrodEnd(testData)) {
this.playLocalAudio("right");
asyncPlayDragonBoneAnimation(cat, "right", 1);
await this.showVoiceGood();
this.hideVoice();
return resolve(true);
} else {
this.playLocalAudio("wrong");
asyncPlayDragonBoneAnimation(cat, "wrong", 1);
await this.showVoiceTry();
this.hideVoice();
return resolve(false);
}
}
// await pg.time.delay(5);
window.courseware &&
window.courseware.stopTest(async (data) => {
this.recordWaitCount++;
data = JSON.parse(data);
if (this.recrodEnd(data)) {
this.playLocalAudio("right");
asyncPlayDragonBoneAnimation(cat, "right", 1);
await this.showVoiceGood();
this.hideVoice();
return resolve(true);
} else {
this.playLocalAudio("错误弹回");
asyncPlayDragonBoneAnimation(cat, "wrong", 1);
await this.showVoiceTry();
this.hideVoice();
return resolve(false);
}
// await pg.time.delay(5);
window.courseware && window.courseware.stopTest(async (data) => {
this.recordWaitCount++;
data = JSON.parse(data);
if (this.recrodEnd(data)) {
// this.playLocalAudio("正确");
await this.showVoiceGood();
this.hideVoice();
return resolve(true)
} else {
// this.playLocalAudio("错误弹回");
await this.showVoiceTry();
this.hideVoice();
return resolve(false);
}
}); //结束录音
}, 4000);
// })
});
},
}); //结束录音
}, 4000);
});
});
},
showVoiceGood() {
return new Promise((resolve, reject) => {
let voice = this.node;
voice.active = true;
let imgLight = voice.getChildByName("bg_light");
let imgGood = voice.getChildByName("good");
let imgTry = voice.getChildByName("try");
imgLight.active = true;
cc.Tween.stopAllByTarget(imgLight);
cc.tween(imgLight)
.by(3, { angle: 360 })
.repeatForever()
.start();
imgGood.active = true;
imgTry.active = false;
setTimeout(() => {
resolve('');
}, 2000);
});
},
showVoiceGood() {
return new Promise((resolve, reject) => {
let voice = this.node;
voice.active = true;
let imgLight = voice.getChildByName("bg_light");
let imgGood = voice.getChildByName("good");
let imgTry = voice.getChildByName("try");
imgLight.active = true;
cc.Tween.stopAllByTarget(imgLight);
cc.tween(imgLight).by(3, { angle: 360 }).repeatForever().start();
imgGood.active = true;
imgTry.active = false;
setTimeout(() => {
resolve("");
}, 2000);
});
},
showVoiceTry() {
return new Promise((resolve, reject) => {
let voice = this.node;
voice.active = true;
let imgLight = voice.getChildByName("bg_light");
let imgGood = voice.getChildByName("good");
let imgTry = voice.getChildByName("try");
imgLight.active = true;
cc.Tween.stopAllByTarget(imgLight);
cc.tween(imgLight)
.by(3, { angle: 360 })
.repeatForever()
.start();
imgGood.active = false;
imgTry.active = true;
setTimeout(() => {
resolve('');
}, 2000);
});
},
recrodEnd(data) {
// return true;
let score = data.result.overall;
let isSuccess = this.checkWords(data);
console.log("score->" + score);
console.log("isSuccess->" + isSuccess);
if (score >= 70 && isSuccess) {
return true;
} else {
return false;
}
},
checkWords(data) {
const sentences = data.result.sentences;
if (!sentences) return true;
for (let i = 0; i < sentences.length; i++) {
const details = sentences[i].details;
const isSuccess = details.some(item => item.overall <= 40);
if (isSuccess) return false;
}
return true;
},
hideVoice() {
let voice = this.node;
voice.active = false;
}
showVoiceTry() {
return new Promise((resolve, reject) => {
let voice = this.node;
voice.active = true;
let imgLight = voice.getChildByName("bg_light");
let imgGood = voice.getChildByName("good");
let imgTry = voice.getChildByName("try");
imgLight.active = true;
cc.Tween.stopAllByTarget(imgLight);
cc.tween(imgLight).by(3, { angle: 360 }).repeatForever().start();
imgGood.active = false;
imgTry.active = true;
setTimeout(() => {
resolve("");
}, 2000);
});
},
recrodEnd(data) {
// return true;
let score = data.result.overall;
let isSuccess = this.checkWords(data);
console.log("score->" + score);
console.log("isSuccess->" + isSuccess);
if (score >= 70 && isSuccess) {
return true;
} else {
return false;
}
},
checkWords(data) {
const sentences = data.result.sentences;
if (!sentences) return true;
for (let i = 0; i < sentences.length; i++) {
const details = sentences[i].details;
const isSuccess = details.some((item) => item.overall <= 40);
if (isSuccess) return false;
}
return true;
},
hideVoice() {
let voice = this.node;
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 @@
},
{
"__id__": 33
},
{
"__id__": 36
}
],
"_active": true,
"_active": false,
"_components": [
{
"__id__": 36
"__id__": 44
},
{
"__id__": 37
"__id__": 45
}
],
"_prefab": {
"__id__": 38
"__id__": 46
},
"_opacity": 255,
"_color": {
......@@ -1342,6 +1345,272 @@
"fileId": "c8TTnwgvpL2Kb1J1NCiHC8",
"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",
"_name": "",
......@@ -1377,6 +1646,8 @@
"__id__": 1
},
"_enabled": true,
"audioBeforeTest": "",
"recordWaitCount": 0,
"_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 @@
"rawHeight": 51,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"borderLeft": 38,
"borderRight": 16,
"subMetas": {}
}
}
......
......@@ -96,25 +96,25 @@
"__id__": 217
},
{
"__id__": 255
"__id__": 263
},
{
"__id__": 256
"__id__": 264
},
{
"__id__": 257
"__id__": 265
}
],
"_active": true,
"_components": [
{
"__id__": 265
"__id__": 273
},
{
"__id__": 266
"__id__": 274
},
{
"__id__": 267
"__id__": 275
}
],
"_prefab": null,
......@@ -10847,19 +10847,22 @@
},
{
"__id__": 249
},
{
"__id__": 252
}
],
"_active": false,
"_components": [
{
"__id__": 252
"__id__": 260
},
{
"__id__": 253
"__id__": 261
}
],
"_prefab": {
"__id__": 254
"__id__": 262
},
"_opacity": 255,
"_color": {
......@@ -10883,8 +10886,8 @@
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
1280,
960,
0,
0,
0,
......@@ -10906,7 +10909,7 @@
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "79NB9B0J1FfauSvPDUXMbh"
"_id": "75T40zECtOHZ/PNIbc2zBZ"
},
{
"__type__": "cc.Node",
......@@ -10973,7 +10976,7 @@
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "25eIyBPg5KTKYeW1jVd5hq"
"_id": "ddzAmTzuVITaOoE1N7BCZH"
},
{
"__type__": "cc.Sprite",
......@@ -11005,7 +11008,7 @@
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": "d3niGuB7hAZ4BSc8vWkjTl"
"_id": "2fRl7/ZLlJSarpHEremvst"
},
{
"__type__": "cc.Widget",
......@@ -11032,7 +11035,7 @@
"_isAbsVerticalCenter": true,
"_originalWidth": 50000,
"_originalHeight": 50000,
"_id": "59XcWTDXVB95RS6FgQqh+i"
"_id": "a5spwm7L9JeqAiDFb82ZOQ"
},
{
"__type__": "cc.PrefabInfo",
......@@ -11107,7 +11110,7 @@
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "f93KPVOY9CZrOTBk8Bve7h"
"_id": "29v0F+8INF4K5Yi1ml40nK"
},
{
"__type__": "cc.Sprite",
......@@ -11139,7 +11142,7 @@
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": "24r1x8rhxI/7yqShCECNCc"
"_id": "71925cD3xDRosrohdHWJ7O"
},
{
"__type__": "cc.PrefabInfo",
......@@ -11221,7 +11224,7 @@
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "6elb8plVtISIgk6DNuRClg"
"_id": "794qnVDp5Li5VDUv2YfzFq"
},
{
"__type__": "cc.Node",
......@@ -11285,7 +11288,7 @@
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "f4S9uq0mdKeIxAP84PTlnK"
"_id": "d2lE+bhI5Nt7ll6nwKxSXm"
},
{
"__type__": "dragonBones.ArmatureDisplay",
......@@ -11325,7 +11328,7 @@
"_N$timeScale": 1,
"_N$debugBones": false,
"_N$enableBatch": false,
"_id": "d8jZh7qctI4Y4H8xmkly60"
"_id": "eaHuu4h7BFdJsPszHnMCWC"
},
{
"__type__": "cc.PrefabInfo",
......@@ -11400,7 +11403,7 @@
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "b97wBzAB5Pk4L2olvLd2WX"
"_id": "d7BdU+23NFlq0gus9fb6Rq"
},
{
"__type__": "cc.Button",
......@@ -11468,7 +11471,7 @@
"hoverSprite": null,
"_N$disabledSprite": null,
"_N$target": null,
"_id": "d9Ji/J+eVHSLuGOKaX9toC"
"_id": "fbQbgiOVNLnJVg64xhTeCs"
},
{
"__type__": "cc.PrefabInfo",
......@@ -11506,7 +11509,7 @@
"_isAbsVerticalCenter": true,
"_originalWidth": 0,
"_originalHeight": 0,
"_id": "96D6C5Zy1LFJqgyqPFceqN"
"_id": "b0PeZu5etOsKr93+sWOWPK"
},
{
"__type__": "cc.PrefabInfo",
......@@ -11577,7 +11580,7 @@
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "37naXtTW5DNqWWbCt6ovxK"
"_id": "d3Vofx3K9J5Ko1hQXoPY2Z"
},
{
"__type__": "cc.PrefabInfo",
......@@ -11659,7 +11662,7 @@
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "c06Ofer4xGT5nReH61vg4R"
"_id": "8258XoFCJG4oT7vFhaLNDC"
},
{
"__type__": "cc.Node",
......@@ -11723,7 +11726,7 @@
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "72BPWdVsBFJ6wOcBGv7ZF1"
"_id": "40lesAfrZGQLCSYqjAnS/N"
},
{
"__type__": "cc.Sprite",
......@@ -11755,7 +11758,7 @@
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": "efNSA72WZM0aHS0MzOWcxj"
"_id": "62OI4sCt9LhYPvxdhYlAfk"
},
{
"__type__": "cc.PrefabInfo",
......@@ -11798,7 +11801,7 @@
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": "43SBOBZsNIp6oQaK5gRajw"
"_id": "68wU0rYslCcpa1ajuz+3b1"
},
{
"__type__": "cc.ProgressBar",
......@@ -11815,7 +11818,7 @@
"_N$mode": 0,
"_N$progress": 1,
"_N$reverse": false,
"_id": "85Ehaed7ZGqbFRo5psxOKm"
"_id": "dctEEwOqNIDYbNBqclw8jK"
},
{
"__type__": "cc.PrefabInfo",
......@@ -11890,7 +11893,7 @@
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "35OlO/V6NJpJRA8ui8RcXy"
"_id": "47p3W1uA5FY6svtCMOxpu8"
},
{
"__type__": "cc.Sprite",
......@@ -11922,7 +11925,7 @@
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": "0cm8SN1S9GOJKWi3DCrlcv"
"_id": "a2POaVqS1LE5wRVy+3zsYN"
},
{
"__type__": "cc.PrefabInfo",
......@@ -11997,7 +12000,7 @@
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "deMplk1T5PeqUjlShlc1/7"
"_id": "7dxPpEXjlEvb3csggtDs6R"
},
{
"__type__": "cc.Sprite",
......@@ -12029,7 +12032,7 @@
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": "31WxfUs6tMv4flNn2WhkGX"
"_id": "8fQkQ+22JLnYP+7gxO7M7h"
},
{
"__type__": "cc.PrefabInfo",
......@@ -12104,7 +12107,7 @@
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "51v7JUPkpKZoy1EdfwK1Qx"
"_id": "cfeNuCAvxOOrvcwNzWAKxH"
},
{
"__type__": "cc.Sprite",
......@@ -12136,7 +12139,7 @@
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": "6bXtyznwtAnrgnfTI7jks/"
"_id": "9c66G9YbdJc5LfqNu2no4R"
},
{
"__type__": "cc.PrefabInfo",
......@@ -12149,6 +12152,272 @@
"fileId": "c8TTnwgvpL2Kb1J1NCiHC8",
"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",
"_name": "",
......@@ -12174,7 +12443,7 @@
"_isAbsVerticalCenter": true,
"_originalWidth": 0,
"_originalHeight": 0,
"_id": "f5JGE+TeFJ5oPBAawSIokG"
"_id": "5awcLiOtZM9o4KbIW9/h0L"
},
{
"__type__": "16155YRBRBLL4FPRlTZRpiI",
......@@ -12184,7 +12453,9 @@
"__id__": 217
},
"_enabled": true,
"_id": "8dfkVpHmxCl5/dY7sHIxjD"
"audioBeforeTest": "",
"recordWaitCount": 0,
"_id": "3fY+V+UrRMDbcbChKnthRF"
},
{
"__type__": "cc.PrefabInfo",
......@@ -12322,13 +12593,13 @@
},
"_children": [
{
"__id__": 258
"__id__": 266
},
{
"__id__": 261
"__id__": 269
},
{
"__id__": 262
"__id__": 270
}
],
"_active": false,
......@@ -12386,11 +12657,11 @@
"_name": "font",
"_objFlags": 0,
"_parent": {
"__id__": 257
"__id__": 265
},
"_children": [
{
"__id__": 259
"__id__": 267
}
],
"_active": true,
......@@ -12448,13 +12719,13 @@
"_name": "BRLNSDB",
"_objFlags": 0,
"_parent": {
"__id__": 258
"__id__": 266
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 260
"__id__": 268
}
],
"_prefab": null,
......@@ -12510,7 +12781,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 259
"__id__": 267
},
"_enabled": true,
"_materials": [],
......@@ -12541,7 +12812,7 @@
"_name": "img",
"_objFlags": 0,
"_parent": {
"__id__": 257
"__id__": 265
},
"_children": [],
"_active": true,
......@@ -12599,11 +12870,11 @@
"_name": "audio",
"_objFlags": 0,
"_parent": {
"__id__": 257
"__id__": 265
},
"_children": [
{
"__id__": 263
"__id__": 271
}
],
"_active": true,
......@@ -12661,13 +12932,13 @@
"_name": "btn",
"_objFlags": 512,
"_parent": {
"__id__": 262
"__id__": 270
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 264
"__id__": 272
}
],
"_prefab": null,
......@@ -12723,7 +12994,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 263
"__id__": 271
},
"_enabled": true,
"_clip": {
......
......@@ -27,6 +27,7 @@ const MSG_PLAYER_TO_HOME = "msg_player_to_home";
const MSG_PROFIX_END = "__END__";
const DEBUG = true;
const TOTAL_SCORE = 42; // 总分 - 双方分数之和等于 TOTAL_SCORE
const AI_SUCCESS_RATE = 0.85; // ai评测成功率
@ccclass
export default class SceneComponent extends MyCocosSceneComponent {
......@@ -152,6 +153,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.initLoadingLayer();
this.initOfflineLayer();
this.initPronunciationTestLayer();
this.initCoolCat();
this.initTurntable();
this.initGemstone();
this.initScore();
......@@ -210,6 +212,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
initPronunciationTestLayer() {
const loadingLayerBase = cc.find("Canvas/PronunciationTestLayer");
this.pronunciationTestLayer = loadingLayerBase.getComponent("PronunciationTestLayer");
this.pronunciationTestLayer.init("http://staging-teach.cdn.ireadabc.com/31952573236dd316a8ee1672d1614a1c.mp3")
}
redPlayerNode = null;
......@@ -238,6 +241,12 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.treeNode = cc.find("Canvas/center_map/tree/stand");
}
// 初始化酷猫
coolCat = null;
initCoolCat() {
this.coolCat = cc.find("Canvas/coolcatLand/coolcat");
}
// 小人上树
playerToTree(playerNode) {
const wordPos = this.treeNode.convertToWorldSpaceAR(cc.v2(0, 0))
......@@ -700,7 +709,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
if(isAi) {
setTimeout(() => {
console.log("语音评测结束")
if(Math.random() > 1) {
if(Math.random() > AI_SUCCESS_RATE) {
console.log("评测失败,后退")
// 后退
this.runEvent(MSG_PLAYER_TO_HOME, {success: false, gemIndex: param.index});
......@@ -711,7 +720,9 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
}, DEBUG?10:2000);
} else {
this.coolCat.active = false;
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});
})
}
......
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