Commit e089d14b authored by linzhiguo's avatar linzhiguo

+ 最多8道题,翻倍,随机干扰项

+ 对错处理
+ 时间加倍
+ 大小写都正确
parent 03ed217a
...@@ -162,9 +162,57 @@ cc.Class({ ...@@ -162,9 +162,57 @@ cc.Class({
this.initView(); this.initView();
}, },
handleData(data){
let arr = {};
arr.time = data.time*2;
let len = data.mouses.length;
if (len == 1)
return data;
if (len > 8)
len = 8;
arr.title = data.title;
arr.audio_url = data.audio_url;
arr.mouses = [];
let words = [];
for(let i = 0; i < len; i++){
words[i] = data.mouses[i].word;
arr.mouses[i] = {};
arr.mouses[i].word = data.mouses[i].word;
arr.mouses[i].correct = true;
arr.mouses[i].audio_url = data.mouses[i].audio_url;
}
let letter, tmp, j, k;
for(let i = 0; i < len; i++){
j = i+ len;
arr.mouses[j] = {};
letter = data.mouses[i].word;
do {
k = RandomInt(len, i);
}while(letter == words[k])
tmp = words[k];
words[k] = words[i];
words[i] = tmp;
arr.mouses[j].word = tmp;
arr.mouses[j].correct = letter == tmp.toUpperCase() || letter == tmp.toLowerCase();
arr.mouses[j].audio_url = data.mouses[i].audio_url;
}
return arr;
},
initView() { initView() {
window.WL = this; window.WL = this;
this.data = this.handleData(this.data);
this.shuffle(this.data.mouses); this.shuffle(this.data.mouses);
console.log(this.data.mouses);
this._touched = false; this._touched = false;
...@@ -205,9 +253,7 @@ cc.Class({ ...@@ -205,9 +253,7 @@ cc.Class({
this._hammer.x = pos.x; this._hammer.x = pos.x;
this._hammer.y = pos.y; this._hammer.y = pos.y;
this._touched = false; this._touched = false;
this.playAudioByName('correct', ()=>{ this.playAudioByName(this.hit_result?'correct':'incorrect');
});
cc.tween(item) cc.tween(item)
.delay(0.5) .delay(0.5)
.call(()=>{ .call(()=>{
...@@ -287,6 +333,8 @@ cc.Class({ ...@@ -287,6 +333,8 @@ cc.Class({
this._time_ani = null; this._time_ani = null;
} }
this.hit_result = info.correct;
for(let i = 0; i < len; i++){ for(let i = 0; i < len; i++){
item = this.mouses[i]; item = this.mouses[i];
item.y = item._y1; item.y = item._y1;
...@@ -357,7 +405,7 @@ cc.Class({ ...@@ -357,7 +405,7 @@ cc.Class({
}, },
updateFlag(){ updateFlag(){
if (this._flag_index >= this.data.mouses.length) if (this._flag_index >= this.data.mouses.length || this.hit_result == false)
return; return;
let idx = this.data.mouses.length - this._flag_index - 1; let idx = this.data.mouses.length - this._flag_index - 1;
......
...@@ -6,7 +6,7 @@ export const defaultData = ...@@ -6,7 +6,7 @@ export const defaultData =
"audio_url": "http://staging-teach.cdn.ireadabc.com/dd360bbbcf5817eea26ac5fa3341ef5d.mp3" "audio_url": "http://staging-teach.cdn.ireadabc.com/dd360bbbcf5817eea26ac5fa3341ef5d.mp3"
}, },
{ {
"word": "O" "word": "A"
}, },
{ {
"word": "u", "word": "u",
......
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