Commit f92c3243 authored by Tt's avatar Tt

1

parent 5f50bcfe
This diff is collapsed.
...@@ -103,6 +103,15 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -103,6 +103,15 @@ export default class SceneComponent extends MyCocosSceneComponent {
pg.view.touchOn(this.btn_last, this.preLayer, this); pg.view.touchOn(this.btn_last, this.preLayer, this);
pg.view.touchOn(this.btn_next, this.nextLayer, this); pg.view.touchOn(this.btn_next, this.nextLayer, this);
pg.view.touchOn(this.btn_voice, this.onTouchVoice, this); pg.view.touchOn(this.btn_voice, this.onTouchVoice, this);
pg.view.touchOn(this.btn_record, this.onTouchRecord, this);
let layout_btns = pg.view.find(this.btn_record, "mask/layout_btns");
let btn_right = pg.view.find(layout_btns, 'btn_right')
let btn_play = pg.view.find(layout_btns, 'btn_play')
let btn_stop = pg.view.find(layout_btns, 'btn_stop')
pg.view.touchOn(btn_right, this.onTouchRecordRight, this);
pg.view.touchOn(btn_play, this.onTouchRecordPlay, this);
pg.view.touchOn(btn_stop, this.onTouchRecordStop, this);
} }
private get LastData() { private get LastData() {
...@@ -161,7 +170,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -161,7 +170,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.letter = this.CurrentData.content; this.letter = this.CurrentData.content;
this.targetTime = this.CurrentData.duration; this.targetTime = this.CurrentData.duration;
this.scheduleOnce(() => { this.scheduleOnce(() => {
this.onTouchRecord(); this.showRecordWait();
}, 1) }, 1)
}, (audioId) => { }, (audioId) => {
this.currentAudioId = audioId; this.currentAudioId = audioId;
...@@ -203,8 +212,6 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -203,8 +212,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
update() { update() {
if (!this.list) return; if (!this.list) return;
this.updateBtns(); this.updateBtns();
// this.updateCountdown(dt);
this.showTimeUpdate();
} }
//--------------------------------Record----------------------------- //--------------------------------Record-----------------------------
private letter: string; private letter: string;
...@@ -215,43 +222,9 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -215,43 +222,9 @@ export default class SceneComponent extends MyCocosSceneComponent {
private microPhoneChange: boolean; private microPhoneChange: boolean;
@property(cc.Node)
public label_time: cc.Node = null;
@property(cc.Node) @property(cc.Node)
public btn_record: cc.Node = null; public btn_record: cc.Node = null;
showTimeStart() {
if (!this.targetTime) return;
let nowTime = new Date().getTime();
this.startTime = nowTime;
}
showTimeUpdate() {
if (!this.startTime) return;
let nowTime = new Date().getTime();
let subTime = this.targetTime - (nowTime - this.startTime) / 1000 + 1;
if (subTime < 0) subTime = 0;
pg.view.setString(this.label_time, `${Math.floor(subTime)}`)
if (subTime == 0) {
this.onTouchRecordEnd(false);
}
}
showTimeEnd() {
this.startTime = null;
}
showVoiceFlash() {
pg.view.visible(this.btn_record, true)
this.btn_record.y = -550;
cc.tween(this.btn_record).to(0.3, { y: 0 }).start();
let com = this.btn_record.getChildByName("img_voice").getComponent(ImgAuto);
com.playVoiceStart();
}
hideVoiceFlash() {
pg.view.visible(this.btn_record, false)
let com = this.btn_record.getChildByName("img_voice").getComponent(ImgAuto);
com.playVoiceEnd();
}
log(str) { log(str) {
const node = cc.find('middleLayer'); const node = cc.find('middleLayer');
if (node) { if (node) {
...@@ -261,6 +234,58 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -261,6 +234,58 @@ export default class SceneComponent extends MyCocosSceneComponent {
} }
} }
// 展示点击效果
async showRecordWait() {
pg.view.find(this.btn_record, 'bg/ani').active = true;
}
async showRecordWaitEnd() {
pg.view.find(this.btn_record, 'bg/ani').active = false;
}
async showRecordIng() {
let img_voice = pg.view.find(this.btn_record, "img_voice");
img_voice.active = true;
img_voice.getComponent(ImgAuto).playVoiceStart();
// 按钮区域显示 显示对应的对错
let layout_btns = pg.view.find(this.btn_record, "mask/layout_btns");
layout_btns.x = -160
cc.tween(layout_btns).to(0.5, { x: 160 }).start();
let btn_right = pg.view.find(layout_btns, 'btn_right')
let btn_play = pg.view.find(layout_btns, 'btn_play')
let btn_stop = pg.view.find(layout_btns, 'btn_stop')
btn_right.active = true;
btn_play.active = false;
btn_stop.active = false;
}
async showRecordEnd() {
let img_voice = pg.view.find(this.btn_record, "img_voice");
img_voice.active = false;
img_voice.getComponent(ImgAuto).playVoiceEnd();
// 按钮区域显示
let layout_btns = pg.view.find(this.btn_record, "mask/layout_btns");
let btn_right = pg.view.find(layout_btns, 'btn_right')
let btn_play = pg.view.find(layout_btns, 'btn_play')
let btn_stop = pg.view.find(layout_btns, 'btn_stop')
btn_right.active = false;
btn_play.active = false;
btn_stop.active = false;
}
// 停止录音
onTouchRecordRight() {
this.onTouchRecordEnd(false);
}
// 停止播放录音
onTouchRecordStop() {
}
// 手动播放录音
onTouchRecordPlay() {
}
//按钮触发,使用的方法 //按钮触发,使用的方法
async onTouchRecord() { async onTouchRecord() {
if (this.recording) return; if (this.recording) return;
...@@ -268,8 +293,8 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -268,8 +293,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.recording = true; this.recording = true;
this.recordAudio = ''; this.recordAudio = '';
this.voiceTouchForbid = true; this.voiceTouchForbid = true;
this.showTimeStart(); this.showRecordWaitEnd();
this.showVoiceFlash(); this.showRecordIng();
this.log("-----------------------startTest") this.log("-----------------------startTest")
cc.audioEngine.stopAllEffects(); cc.audioEngine.stopAllEffects();
...@@ -277,8 +302,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -277,8 +302,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
} }
async onTouchRecordEnd(isClear) { async onTouchRecordEnd(isClear) {
if (!this.recording) return; if (!this.recording) return;
this.showTimeEnd(); this.showRecordEnd();
this.hideVoiceFlash();
let testData = { let testData = {
"audioUrl": "https://staging-teach.cdn.ireadabc.com/bea0ba87bcf8bc09815f34b4790ffac9.mp3", "audioUrl": "https://staging-teach.cdn.ireadabc.com/bea0ba87bcf8bc09815f34b4790ffac9.mp3",
"eof": 1, "file": "/storage/emulated/0/Android/data/com.example.oxford/cache/shengtong/gradeVoice.mp3", "eof": 1, "file": "/storage/emulated/0/Android/data/com.example.oxford/cache/shengtong/gradeVoice.mp3",
...@@ -313,7 +337,6 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -313,7 +337,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
} }
async recrodEnd(isClear, data) { async recrodEnd(isClear, data) {
this.voiceTouchForbid = false; this.voiceTouchForbid = false;
this.hideVoiceFlash();
let score = data.result.overall; let score = data.result.overall;
this.log("---------------recrodEnd score:" + score) this.log("---------------recrodEnd score:" + score)
this.recording = false; this.recording = false;
...@@ -508,6 +531,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -508,6 +531,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
} }
createLayer() { createLayer() {
this.layer_item.active = false;
let layer = pg.view.clone(this.layer_item); let layer = pg.view.clone(this.layer_item);
layer.active = true; layer.active = true;
this.layout_item.addChild(layer) this.layout_item.addChild(layer)
...@@ -534,11 +558,28 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -534,11 +558,28 @@ export default class SceneComponent extends MyCocosSceneComponent {
public btn_voice: cc.Node = null; public btn_voice: cc.Node = null;
updateLayer(layer, data) { updateLayer(layer, data) {
// 根据数据来渲染 // 根据数据来渲染
let img = pg.view.find(layer, 'img'); let itemBg1 = pg.view.find(layer, 'bg_1')
let itemBg2 = pg.view.find(layer, 'bg_2')
let itemBg3 = pg.view.find(layer, 'bg_3')
let item = null;
let wh = [];
if (data.imageBig == 1) {
item = itemBg1;
wh = [960, 720]
} else if (data.imageBig == 2) {
item = itemBg2;
wh = [1164, 656]
} else {
item = itemBg3;
wh = [1246, 624]
}
itemBg1.active = false;
itemBg2.active = false;
itemBg3.active = false;
item.active = true;
let img = pg.view.find(item, 'img');
img.active = true; img.active = true;
// 需要根据图片设定的类型来动态的识别对应的图片大小 和不同的背景图 pg.view.setNetImg(img, data.image, { w: wh[0], h: wh[1] })
pg.view.setNetImg(img, data.image, { w: 1330, h: 655 })
} }
onTouchVoice(e) { onTouchVoice(e) {
......
...@@ -17,12 +17,14 @@ export const defaultData = ...@@ -17,12 +17,14 @@ export const defaultData =
"duration": 5, "duration": 5,
"content": "yes,It is Annie's apple tree.", "content": "yes,It is Annie's apple tree.",
"right": false, "right": false,
"imageBig": 1, "imageBig": 3,
"audioName": "btn_hy01_danci.mp3" "audioName": "btn_hy01_danci.mp3"
}, { }, {
"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 in air", "duration": 10, "content": "clound is cloud", "right": false, "audioName": "敲碎蛋的声音.mp3", "imageBig": 2 "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 in air", "duration": 10,
"content": "clound is cloud", "right": false, "audioName": "敲碎蛋的声音.mp3", "imageBig": 2
}, { }, {
"type": "img_txt_audio", "imageBig": 3, "image": "http://staging-teach.cdn.ireadabc.com/ef1e6f871b37ad482e268809e91d20b7.png", "audio": "http://staging-teach.cdn.ireadabc.com/5f4e4c72671607bb35d1ecd1d291f238_l.mp3", "text": "", "duration": 10, "content": "", "right": false, "audioName": "excellent_dg10_ty.mp3" "type": "img_txt_audio", "imageBig": 1, "image": "http://staging-teach.cdn.ireadabc.com/ef1e6f871b37ad482e268809e91d20b7.png", "audio": "http://staging-teach.cdn.ireadabc.com/5f4e4c72671607bb35d1ecd1d291f238_l.mp3", "text": "", "duration": 10, "content": "", "right": false, "audioName": "excellent_dg10_ty.mp3"
}] }]
}], }],
"bgAudio": "", "bgAudioName": "", "audioName": "", "npcTitle": "test", "bgAudio": "", "bgAudioName": "", "audioName": "", "npcTitle": "test",
......
...@@ -125,13 +125,13 @@ ...@@ -125,13 +125,13 @@
<div style="margin-top: 5px;"> <div style="margin-top: 5px;">
<nz-radio-group [(ngModel)]="option.imageBig" (ngModelChange)="ngChange(i,j)"> <nz-radio-group [(ngModel)]="option.imageBig" (ngModelChange)="ngChange(i,j)">
<label nz-radio [nzValue]="1"> <label nz-radio [nzValue]="1">
<span [style]="{color:option.imageBig== 1 ? '#169BD5':'#000'}">大图片</span> <span [style]="{color:option.imageBig== 3 ? '#169BD5':'#000'}">大图片</span>
</label> </label>
<label nz-radio [nzValue]="2"> <label nz-radio [nzValue]="2">
<span [style]="{color:option.imageBig== 2 ? '#169BD5':'#000'}">中图片</span> <span [style]="{color:option.imageBig== 2 ? '#169BD5':'#000'}">中图片</span>
</label> </label>
<label nz-radio [nzValue]="3"> <label nz-radio [nzValue]="3">
<span [style]="{color:option.imageBig== 3 ? '#169BD5':'#000'}">小图片</span> <span [style]="{color:option.imageBig== 1 ? '#169BD5':'#000'}">小图片</span>
</label> </label>
</nz-radio-group> </nz-radio-group>
</div> </div>
......
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