Commit 1a3c7758 authored by liujiangnan's avatar liujiangnan

feat

parent 6e65fe8f
......@@ -15,23 +15,15 @@ const { ccclass, property } = cc._decorator;
export default class SceneComponent extends MyCocosSceneComponent {
addPreloadImage() {
this._imageResList.push(...this.data.questions.map(question => {
return { url: question.image };
}));
this._imageResList.push(...this.data.questions.map(question => {
return { url: question.image2 };
this._imageResList.push(...this.data.pages.map(question => {
return { url: question.pic_url };
}));
}
addPreloadAudio() {
this._audioResList.push(...this.data.questions.map(question => {
return { url: question.audio };
}));
this._audioResList.push(...this.data.questions.map(question => {
return { url: question.audio2 };
this._audioResList.push(...this.data.pages.map(question => {
return { url: question.audio_url };
}));
this._audioResList.push({ url: this.data.npcAudio });
}
addPreloadAnima() {
......@@ -188,14 +180,12 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.btn_play.active = data.recordAudio;
this.btn_stop.active = false;
this.btn_laba.active = !!data.audio;
this.btn_laba.active = !!data.audio_url;
}
private intervalId;
private stop;
private onLaba() {
this.playTitleAudio(Game.getIns().lists[this.page].audio, () => {
this.playTitleAudio(Game.getIns().lists[this.page].audio2);
});
this.playTitleAudio(Game.getIns().lists[this.page].audio_url);
}
private playTitleAudio(audio, cb = null) {
this.resetAudio();
......@@ -244,12 +234,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
if (Game.getIns().lists[this.page].text) {
text += Game.getIns().lists[this.page].text;
}
if (Game.getIns().lists[this.page].text2) {
if (text) {
text += " ";
}
text += Game.getIns().lists[this.page].text2;
}
if (window['courseware']) {
window['courseware'].startTest(text);
}
......@@ -335,16 +319,14 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
private timeOut;
private playQuestionAudio() {
this.playTitleAudio(Game.getIns().lists[this.page].audio, (audioId) => {
this.playTitleAudio(Game.getIns().lists[this.page].audio2, (audioId2) => {
this.playTitleAudio(Game.getIns().lists[this.page].audio_url, (audioId) => {
if (this.autoPlay == 0) return;
let time = audioId2 ? 1000 : 3000;
let time = audioId ? 1000 : 3000;
this.timeOut = setTimeout(() => {
let index = this.page_view.getComponent(cc.PageView).getCurrentPageIndex();
this.page_view.getComponent(cc.PageView).scrollToPage(index + 1, 0.1);
}, time);
})
})
}
private nextPage() {
this.createCrads();
......@@ -370,18 +352,9 @@ export default class SceneComponent extends MyCocosSceneComponent {
for (let index = 0; index < list.length; index++) {
let question = list[index]
const group = cc.instantiate(this.layout_pic);
if (!question.image2) {
let pic = cc.find("pic", group);
await pg.view.setNetImg(pic, question.image, { w: 943, h: 1024 }, true);
await pg.view.setNetImg(pic, question.pic_url, { w: 943, h: 1024 }, true);
cc.find("pic2", group).active = false;
} else {
const pic = cc.find("pic", group);
await pg.view.setNetImg(pic, question.image, { w: 800, h: 1024 }, true);
pic.x = -400;
const pic2 = cc.find("pic2", group);
await pg.view.setNetImg(pic2, question.image2, { w: 800, h: 1024 }, true);
pic2.x = 400;
}
// 等首图加载完成后 隐藏加载进度条
if (index == 0) {
this.hideMiddleLayerLoading();
......@@ -415,8 +388,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
bg_tryagain.active = data.recordScore >= 0 && data.recordScore < 50;
this.btn_off.active = this.autoPlay == 0;
this.btn_on.active = this.autoPlay == 1;
this.btn_record.active = data.isrecord ==1;
this.btn_noplay.active = !data.recordAudio && (data.text != "" || data.text2 != "");
this.btn_record.active = true;
this.btn_noplay.active = !data.recordAudio;
this.btn_play.active = data.recordAudio;
this.btn_left.active = this.page > 0 && this.autoPlay == 0;
this.btn_right.active = this.page >= 0 && this.page < Game.getIns().len - 1 && this.autoPlay == 0;
......
// export class Option {
// type;
// txt;
// picUrl;
// audioUrl;
// public data;
// public id: number;
// public count: number;
// constructor(data, id) {
// this.id = id;
// this.data = data;
// this.type = data.type;
// this.txt = data.text;
// this.picUrl = data.image;
// this.audioUrl = data.optionAudio;
// }
// }
export class Item {
public page;
public audio;
public audio2;
public image;
public image2;
public pic_url;
public audio_url;
public text;
public text2;
public isrecord;
public type;
public recordScore;
public recordAudio;
public recordScore;
constructor(data, page) {
this.audio = data.audio;
this.audio2 = data.audio2;
this.image = data.image;
this.image2 = data.image2;
this.pic_url = data.pic_url;
this.audio_url = data.audio_url;
this.text = data.text;
this.text2 = data.text2;
this.isrecord = data.isrecord;
this.type = data.type;
this.recordScore = -1;
this.recordAudio = data.recordAudio;
this.recordScore = data.recordScore;
this.page = page;
}
}
......@@ -59,7 +34,7 @@ export default class Game {
public init(data) {
this.start = false;
this.lists = [];
this.data = data.questions;
this.data = data.pages;
}
public start: boolean;
public page: number;
......
......@@ -55,7 +55,7 @@ export class MyCocosSceneComponent extends cc.Component {
if (window && (<any>window).courseware && (<any>window).courseware.getData) {
(<any>window).courseware.getData((data) => {
this.log('data:' + data);
this.data = this.conversionData(data) || this.getDefaultData();
this.data = data || this.getDefaultData();
this.data = JSON.parse(JSON.stringify(this.data));
this.preloadItem();
})
......@@ -65,46 +65,6 @@ export class MyCocosSceneComponent extends cc.Component {
}
}
conversionData(data) {
const dataTemp = {
"score": 0,
"title": "",
"npcAudio": "",
"npcAudioName": "",
"returnType": "0",
"questionText": "",
"questionType": "read",
"questionTextAudio": "",
"questions": [
]
}
data.pages.forEach(item => {
const dataItem = {
"type": "img",
"isrecord": 1,
"audio": "",
"audio2": "",
"text": "",
"text2": "",
"image": "",
"image2": "",
"time": null,
"audioName": "",
"audio2Name": ""
}
dataItem.text = item.text;
dataItem.audio = item.audio_url;
dataItem.image = item.pic_url;
dataTemp.questions.push(dataItem)
});
}
getDefaultData() {
return defaultData;
}
......
export const defaultData = {
"score": 0,
"title": "",
"npcAudio": "http://teach.cdn.ireadabc.com/cd5807dc4f318ce04f52385900a0575a.mp3",
"npcAudioName": "",
"questionText": "",
"questionType": "record",
"questionTextAudio": "",
"questions": [
{
"type": "img",
"autoplay": 0,
"isrecord": 0,
"text": "",
"image": "http://teach.cdn.ireadabc.com/4ee9c3b3a5a9d7bae35a657c87af5815.png",
"time": null,
"audio2": "http://teach.cdn.ireadabc.com/cd5807dc4f318ce04f52385900a0575a.mp3",
"audio2Name": "9f r1.mp3",
"text2": "",
"image2": "http://teach.cdn.ireadabc.com/f9749b8e57c8445d942f131b69ddc6ac.png"
},
{
"type": "img",
"audio": "http://teach.cdn.ireadabc.com/9df2b9c073c2225c9bce8b78bd571cbb.mp3",
"autoplay": 1,
"isrecord": 1,
"text": "Carla crocodile Catches a cold Written by Veronica Wild Illustrated by Peter Campbell ",
"image": "http://teach.cdn.ireadabc.com/d072a2ace31c633f3842677c1859cbe2.png",
"time": null,
"audioName": "9f r2.mp3",
"text2": "",
"image2": "http://teach.cdn.ireadabc.com/c16c9b348dbfb1bb7ffbee01040e209e.png"
},
{
"type": "img",
"audio": "http://teach.cdn.ireadabc.com/a4ce6782fc0e69b5509103544588ba0e.mp3",
"autoplay": 1,
"isrecord": 1,
"text": "Carla crocodile Catches a cold Written by Veronica Wild Illustrated by Peter Campbell ",
"image": "http://teach.cdn.ireadabc.com/213670e5aa397dc2139449d7932a6586.png",
"time": null,
"audioName": "9f r3.mp3",
"text2": "",
"image2": "http://teach.cdn.ireadabc.com/fecc3c6666fa01b4f7e01464d89d7ac6.png"
},
{
"type": "img",
"audio": "http://teach.cdn.ireadabc.com/eb6a639e35468f1ddf0dc993cef8fa62.mp3",
"autoplay": 1,
"isrecord": 1,
"text": "Carla Crocodile was waiting for the bus. She was going to dance class with Hippo. ",
"image": "http://teach.cdn.ireadabc.com/56dec655f74b912ad09d853959f71d59.png",
"time": null,
"audioName": "9f r-p6.mp3",
"audio2": "http://teach.cdn.ireadabc.com/823599ec5db714787db9c60a2e6de96d.mp3",
"audio2Name": "9f r-p7.mp3",
"text2": "Carla and Hippo waited. \"I can't see the bus. I hope we get there betore dance class is over,\" said Hippo. \"We can dance now. We can dance here before the bus comes,\" Carla said. ",
"image2": "http://teach.cdn.ireadabc.com/4d0337abeccee33bf9a67f21514b8772.png"
},
{
"type": "img",
"audio": "http://teach.cdn.ireadabc.com/e2af5586b3a755695d97c34897741344.mp3",
"autoplay": 1,
"isrecord": 1,
"text": "\"Are you ready now, Hippo? You count the beats,\" said Carla \"One,two,three, one,two,three,\" Hippo said. ",
"image": "http://teach.cdn.ireadabc.com/9c85fcaae9a1f33877930add6669141f.png",
"time": null,
"audioName": "B-9f p8.mp3",
"audio2": "http://teach.cdn.ireadabc.com/8dbb43f9a2f261bebc2e3a6dbf48bb59.mp3",
"audio2Name": "B-9f p9.mp3",
"text2": "\"We can dance over the grass before the bus comes,\" Carla said. ",
"image2": "http://teach.cdn.ireadabc.com/87721a0b775512b187cbe0a676a10ba9.png"
},
{
"type": "img",
"audio": "http://teach.cdn.ireadabc.com/1820fe93aa8f9b2e9d74017dc32e613b.mp3",
"autoplay": 1,
"isrecord": 1,
"text": "Some clouds came over and it started to rain. \"One,two,three,one,two,three,\" counted Hippo.",
"image": "http://teach.cdn.ireadabc.com/99732923d0d671c43caf28dea90a2cbc.png",
"time": null,
"audioName": "9f r-p10.mp3",
"text2": "",
"image2": "http://teach.cdn.ireadabc.com/98980cab2f293a9a8a312c0388be346d.png"
},
{
"type": "img",
"audio": "http://teach.cdn.ireadabc.com/24713315b7f85912250e72e0d31639e0.mp3",
"autoplay": 1,
"isrecord": 1,
"text": "\"We won't stop now,\" said Carla. ",
"image": "http://teach.cdn.ireadabc.com/18b845aac80787e250d2aa49c9f72bfa.png",
"time": null,
"audioName": "9f r-p12.mp3",
"text2": "",
"image2": "http://teach.cdn.ireadabc.com/6bf2e2f89652ecf7c1c8d042e3944475.png"
},
{
"type": "img",
"audio": "http://teach.cdn.ireadabc.com/9666d9ddee0e072fc33d9d64c1358b55.mp3",
"autoplay": 1,
"isrecord": 1,
"text": "\"We can dance over the puddles before the bus comes,\" Carla said. Carla and Hippo danced all over the park. ",
"image": "http://teach.cdn.ireadabc.com/48d7b86743d3e696a6ac7b4ef99851a7.png",
"time": null,
"audioName": "9f r-p14.mp3",
"audio2": "http://teach.cdn.ireadabc.com/93f6c2d89f486ed9c35976496c9904f6.mp3",
"audio2Name": "9f r-p15.mp3",
"text2": "Then Hippo said, \"Look! There goes our bus! What will we do now?\" ",
"image2": "http://teach.cdn.ireadabc.com/0e390ba2b467faaf423c29de6a350968.png"
},
{
"type": "img",
"audio": "http://teach.cdn.ireadabc.com/f195de2465da6dab5129683161bac6f9.mp3",
"autoplay": 1,
"isrecord": 1,
"text": "\"We will dance all the way home,\" said Carla. \"One,two,three,one,two-achoo!\"",
"image": "http://teach.cdn.ireadabc.com/06a32b74cb97bebafa1a307a563e867c.png",
"time": null,
"audioName": "9f r-p16.mp3",
"audio2": "",
"text2": "",
"image2": "",
"audio2Name": ""
}
],
"returnType": "0"
"pages":[
{
"pic_url":"http://staging-teach.cdn.ireadabc.com/c8abf7383d65bcbdba8f390785cece60.png",
"audio_url":"http://staging-teach.cdn.ireadabc.com/1c8694612563f4e2da707f1f6a37d066_l.mp3",
"text":"aaaa",
"audio_urlName":"tt.mp3"
},{
"pic_url":"http://staging-teach.cdn.ireadabc.com/f6f4bbef497409fef3c8f1d375893829.png",
"audio_url":"http://staging-teach.cdn.ireadabc.com/1c8694612563f4e2da707f1f6a37d066_l.mp3",
"text":"bbbb",
"audio_urlName":"tt.mp3"
}
]
}
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