Commit 7e914c05 authored by Tt's avatar Tt

流程结束

parent 99131e78
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -43,9 +43,9 @@ export default class SceneComponent extends MyCocosSceneComponent {
private list: Array<{ type, text, right, imgage, duration, content, audio }>;
private recordFlag: boolean;//录音模式
// 单词列表
private word_list: Array<object>;
private wordDataList: Array<object>;
// 当前第几个
private cur_index: number = 0;
private curIndex: number = 0;
initData() {
// 所有全局变量 默认都是null
this._cantouch = true;
......@@ -54,43 +54,15 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.list = data.questions[0].options;
this.layers = [];
this.word_list = [
{
word: 'bight',
answer: ['bigg', 'h', "t"],
isRight: false,
},
{
word: 'Bight',
answer: ['rig', 'hb', "a"],
isRight: false,
}, {
word: 'Cight',
answer: ['rig', 'hb', "c"],
isRight: false,
}, {
word: 'Dight',
answer: ['rig', 'hd', "d"],
isRight: false,
}, {
word: 'Eight',
answer: ['rig', 'he', "f"],
isRight: false,
}, {
word: 'Hight',
answer: ['rig', 'ht', "h"],
isRight: false,
}, {
word: 'Iight',
answer: ['rig', 'hh', "s"],
isRight: false,
},
{
word: 'KighT',
answer: ['rig', 'h', "t"],
isRight: false,
},
]
this.wordDataList = data.questions.map(question => {
return {
img: question.image,
audio: question.audio,
type: question.type,// img
answer: question.letterList.map(letter => letter.text)
}
})
console.log(data);
}
private layer_record: cc.Node;
......@@ -125,10 +97,10 @@ export default class SceneComponent extends MyCocosSceneComponent {
// 校验是否正确
checkIsRight() {
console.log(this.cur_index + 1 < SceneComponent.Word_List_Len);
console.log(this.curIndex + 1 < SceneComponent.Word_List_Len);
if ((this.cur_index + 1) < SceneComponent.Word_List_Len) {
this.cur_index++
if ((this.curIndex + 1) < SceneComponent.Word_List_Len) {
this.curIndex++
this.showWord()
}
......@@ -138,17 +110,67 @@ export default class SceneComponent extends MyCocosSceneComponent {
private wordBgList: Array<cc.Node>;
private wordList: Array<cc.Node>;
private get CurrentWord(): any {
return this.wordDataList[this.curIndex];
}
nextWord() {
let success = true;
for (let idx in this.successGroupIds) {
if (!this.successGroupIds[idx]) success = false;
}
if (!success) return;
this.scheduleOnce(() => {
pg.event.once('layer_right_show_excellent_end', () => {
this.curIndex++;
if (!this.CurrentWord) {
alert("游戏结束画面暂无")
} else {
this.showWord();
}
})
pg.event.emit('layer_right_show_excellent')
}, 0.2)
}
//单词的展示
showWord() {
this.wordBgList = [];
this.wordList = [];
this.successGroupIds = {};
pg.view.removChildren(this.word_area)
this.initWordBg();
this.initWord();
this.initQuestion();
}
private layer_question: cc.Node;
initQuestion() {
this.layer_question = pg.view.find(this, 'layer_question');
let img = pg.view.find(this.layer_question, 'img');
pg.view.setNetImg(img, this.CurrentWord.img, { w: 230, h: 230 })
let img_voice = pg.view.find(this.layer_question, 'img_voice');
img_voice.active = this.CurrentWord.type != "img";
pg.view.touchOn(img_voice, this.onTouchVoice, this);
}
private audioId;
onTouchVoice() {
if (this.audioId) {
pg.event.emit('img_voice_play_voice_end')
pg.audio.stopAudio(this.audioId)
this.audioId = null;
} else {
pg.event.emit('img_voice_play_voice_start')
pg.audio.playAudioByUrl(this.CurrentWord.audio, () => {
pg.event.emit('img_voice_play_voice_end')
this.audioId = null;
}, (audioId) => {
this.audioId = audioId;
})
}
}
initWordBg() {
let curWord = this.word_list[this.cur_index];
let ansArr = curWord['answer'];
let ansArr = this.CurrentWord.answer;
let count = -1;
ansArr.forEach((ans, i) => {
// 长度大于一需要做拆分
......@@ -157,6 +179,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
count++;
let child = this.getWordBgNodeByStr(str);
child.data = { count: count, group: i, index: m }
this.successGroupIds[`${i}`] = false;
let pos = this.getWordBgPosByAns(ansArr, child.data)
child.x = pos.x;
child.y = pos.y;
......@@ -166,8 +189,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
});
}
initWord() {
let curWord = this.word_list[this.cur_index];
let ansArr = curWord['answer'];
let ansArr = this.CurrentWord.answer;
let itemPrefab = pg.view.find(this.layer_word, 'item');
let count = -1;
ansArr.forEach((ans, i) => {
......@@ -325,8 +347,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
nd.x += delta.x;
nd.y += delta.y;
})
}
private successGroupIds;
onTouchEnd(event) {
let node = event.target;
this.stopCurrentItemAni();
......@@ -344,9 +366,11 @@ export default class SceneComponent extends MyCocosSceneComponent {
let target = targets.find(tr => tr.data.index == item.data.index);
this.wordToWordBg(item, target);
})
this.successGroupIds[`${groupId}`] = true;
node.off(cc.Node.EventType.TOUCH_START, this.onTouchStart, this);
node.off(cc.Node.EventType.TOUCH_MOVE, this.onTouchMove, this);
node.off(cc.Node.EventType.TOUCH_END, this.onTouchEnd, this);
this.nextWord();
} else {
let subX = node.x - node.orgPos.x;
let subY = node.y - node.orgPos.y;
......
export const defaultData =
{
"recordFlag": true,
"title": "test",
"questionText": "",
"questionTextAudio": "",
"questions": [
export const defaultData = {
"onlineFlg": false, "title": "钓鱼大作战", "questionText": "", "questionTextAudio": "http://staging-teach.cdn.ireadabc.com/e422c682ff3304a532937db64573caa4.mp3", "questions": [
{
"questionAudio": "", "duration": 120,
"options": [
{ "type": "img_audio", "image": "http://staging-teach.cdn.ireadabc.com/875862129c75a075b3d710f541258a00.png", "audio": "http://staging-teach.cdn.ireadabc.com/43839adb578c7e01456748b8a176a0c3_l.mp3", "text": "", "duration": 10, "content": "egg", "right": false },
{ "type": "img_txt_audio", "image": "http://staging-teach.cdn.ireadabc.com/011cf423d6fd8760e810644ca6070e34.png", "audio": "http://staging-teach.cdn.ireadabc.com/43839adb578c7e01456748b8a176a0c3_l.mp3", "text": "hammer", "duration": 10, "content": "hammer", "right": false },
{ "type": "img_txt_audio", "image": "http://staging-teach.cdn.ireadabc.com/befdc1801d93fd95b3a8ee7c7a2d2d05.png", "audio": "http://staging-teach.cdn.ireadabc.com/43839adb578c7e01456748b8a176a0c3_l.mp3", "text": "clound", "duration": 10, "content": "clound", "right": false, "audioName": "敲碎蛋的声音.mp3" }]
}], "bgAudio": "", "bgAudioName": "", "audioName": ""
"type": "img", "image": "http://staging-teach.cdn.ireadabc.com/710feaeb43f2b610cfe6946de05c3567.png",
"audio": "", "text": "", "right": false,
"letterList": [{ "text": "c" }, { "text": "a" }, { "text": "p" }, { "text": "able" }]
},
{
"questionAudio": "", "duration": 120, "type": "imgVideo",
"image": "http://staging-teach.cdn.ireadabc.com/cd639cafcc9ce2d23c85815bbf6539ee.png",
"audio": "http://staging-teach.cdn.ireadabc.com/48c425442c9d555e7f1226b81d4b8fa6_l.mp3",
"text": "", "right": false,
"letterList": [{ "text": "g" }, { "text": "o" }, { "text": "o" }, { "text": "d" }],
"audioName": "曾志豪 - 小游戏音乐Ⅱ.mp3"
}
], "bgAudio": "", "bgAudioName": "", "audioName": ""
}
// {
// "recordFlag": true,
......
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