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