Commit 4209edee authored by huoshizhe's avatar huoshizhe

feat:

parent 80e88d37
import { playAudio, playDragonBoneAnimation } from "../script/util"; import { onHomeworkFinish, playAudio, playDragonBoneAnimation } from "../script/util";
import { defaultData } from "../script/defaultData"; import { defaultData } from "../script/defaultData";
cc.Class({ cc.Class({
...@@ -475,6 +475,7 @@ cc.Class({ ...@@ -475,6 +475,7 @@ cc.Class({
this.bar_ani.stop(); this.bar_ani.stop();
this._complete.show(); this._complete.show();
this.playAudioByName('victory'); this.playAudioByName('victory');
onHomeworkFinish();
}, },
// update (dt) {}, // update (dt) {},
......
export const defaultData = { export const defaultData = {
"contentObj": { "contentObj": {
"dataArray": [ "dataArray": [{
{ "time": 5,
"time": 5, "question": {
"question": { "text": "star",
"text": "a", "audio_url": "http://staging-teach.cdn.ireadabc.com/bc0a384c579e3014caef9c2dabea8829.mp3"
"audio_url": "http://staging-teach.cdn.ireadabc.com/dd360bbbcf5817eea26ac5fa3341ef5d.mp3" }
} },
}, {
{ "time": 5,
"time": 5, "question": {
"question": { "text": "angel",
"text": "background", "audio_url": "http://staging-teach.cdn.ireadabc.com/6afb350410aea94f3a2c7460e27429af.mp3"
"audio_url": "http://staging-teach.cdn.ireadabc.com/738ef124b1882d10b31d59fb2fbd7eb7.mp3" }
} }]
}, }
{
"time": 5,
"question": {
"text": "position",
"audio_url": "http://staging-teach.cdn.ireadabc.com/f228f396d2007fc20ab07763ebeda22e.mp3"
}
},
{
"time": 5,
"question": {
"text": "scale",
"audio_url": "http://staging-teach.cdn.ireadabc.com/a812f773f22fdb5fa0de04bc7979f6d7.mp3"
}
},
{
"time": 5,
"question": {
"text": "rotation",
"audio_url": "http://staging-teach.cdn.ireadabc.com/43349451985083b94a58c6870b49f115.mp3"
}
}
]
}
} }
\ No newline at end of file
...@@ -3,70 +3,98 @@ import { RandomInt, playDragonBoneAnimation } from "../script/util"; ...@@ -3,70 +3,98 @@ import { RandomInt, playDragonBoneAnimation } from "../script/util";
cc.Class({ cc.Class({
extends: cc.Component, extends: cc.Component,
name: "MikeButton", name: "MikeButton",
properties: { properties: {
db_item:{ db_item: {
default:null, default: null,
type:cc.Node type: cc.Node
}, },
button:{ button: {
default:null, default: null,
type:cc.Button type: cc.Button
} }
}, },
ctor: function () { ctor: function () {
}, },
onLoad:function(){ onLoad: function () {
this.node.on(cc.Node.EventType.TOUCH_START, this.tapStart, this); this.node.on(cc.Node.EventType.TOUCH_START, this.tapStart, this);
this.node.on(cc.Node.EventType.TOUCH_END, this.tapEnd, this); this.node.on(cc.Node.EventType.TOUCH_END, this.tapEnd, this);
this._down = 0; this._down = 0;
this._up = 0; this._up = 0;
}, },
tapStart(event){ tapStart(event) {
if (this.button.interactable == false) if (this.button.interactable == false) {
return; return;
}
this.db_item.active = true; this.db_item.active = true;
console.log(scene._words[scene._count].word); console.log(scene._words[scene._count].word);
if (window && window.courseware) { if (window && window.courseware) {
window.courseware.startTest(scene._words[scene._count].word); window.courseware.startTest(scene._words[scene._count].word);
} }
const middleLayer = cc.find('middleLayer');
if (middleLayer) {
const middleLayerComponent = middleLayer.getComponent('middleLayer');
middleLayerComponent.startRecordWithText(scene._words[scene._count].word);
}
scene.tapMikeStart(); scene.tapMikeStart();
}, },
tapEnd(event){ tapEnd(event) {
if (this.button.interactable == false) if (this.button.interactable == false) {
return; return;
}
this.db_item.active = false; this.db_item.active = false;
let data; let data;
scene.fallAnimation(); scene.fallAnimation();
if (window && window.courseware) { if (window && window.courseware) {
window.courseware.stopTest((result)=>{ window.courseware.stopTest((result) => {
// data = result; // data = result;
data = JSON.parse(result); data = JSON.parse(result);
this.handleData(data); this.handleData(data);
}); });
} } else {
else{
data = '{ "result" : { "overall" : 62 } }'; data = '{ "result" : { "overall" : 62 } }';
data = JSON.parse(data); data = JSON.parse(data);
data.result.overall = RandomInt(60, 100); data.result.overall = RandomInt(60, 100);
cc.tween(this) cc.tween(this)
.delay(2) .delay(2)
.call(()=>{ .call(() => {
this.handleData(data); this.handleData(data);
}) })
.start(); .start();
return; return;
}
// const middleLayer = cc.find('middleLayer');
// if (middleLayer) {
// const middleLayerComponent = middleLayer.getComponent('middleLayer');
// middleLayerComponent.setTestCallBack((msg) => {
// // console.log('')
// const data = JSON.parse(msg);
// this.handleData(data);
// });
// middleLayerComponent.stopRecord();
// return;
// } else {
// data = '{ "result" : { "overall" : 62 } }';
// data = JSON.parse(data);
// data.result.overall = RandomInt(60, 100);
// cc.tween(this)
// .delay(2)
// .call(() => {
// this.handleData(data);
// })
// .start();
// return;
// }
}
}, },
handleData(data){ handleData(data) {
let v = 2; let v = 2;
if (data&&data.result&&data.result.overall){ if (data && data.result && data.result.overall) {
if (data.result.overall > 85) v = 0; if (data.result.overall > 85) v = 0;
else if (data.result.overall > 70) v = 1; else if (data.result.overall > 70) v = 1;
} }
......
...@@ -360,9 +360,7 @@ export function onHomeworkFinish() { ...@@ -360,9 +360,7 @@ export function onHomeworkFinish() {
const middleLayer = cc.find('middleLayer'); const middleLayer = cc.find('middleLayer');
if (middleLayer) { if (middleLayer) {
const middleLayerComponent = middleLayer.getComponent('middleLayer'); const middleLayerComponent = middleLayer.getComponent('middleLayer');
if (middleLayerComponent.role == 'student') { middleLayerComponent.onHomeworkFinish();
middleLayerComponent.onHomeworkFinish(() => { });
}
} else { } else {
console.log('onHomeworkFinish'); console.log('onHomeworkFinish');
} }
......
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