Commit c81a6f58 authored by Chen Jiping's avatar Chen Jiping

feat:调整逻辑

parent 1c4b52a2
...@@ -8,6 +8,30 @@ ...@@ -8,6 +8,30 @@
<div nz-row> <div nz-row>
<div nz-col [nzSpan]="23" nzOffset="1"> <div nz-col [nzSpan]="23" nzOffset="1">
<nz-divider nzText="内容编辑" nzOrientation="left"></nz-divider> <nz-divider nzText="内容编辑" nzOrientation="left"></nz-divider>
<nz-form-item>
<nz-form-label [nzSpan]="2" nzFor="guideAudioUrl1">开始音频</nz-form-label>
<nz-form-control [nzSpan]="4">
<app-audio-recorder [audioUrl]="item.guideAudioUrl1" id="guideAudioUrl1"
(audioUploaded)="onAudioUploadSuccess($event, item, 'guideAudioUrl1')">
</app-audio-recorder>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSpan]="2" nzFor="guideAudioUrl2">待机音频</nz-form-label>
<nz-form-control [nzSpan]="4">
<app-audio-recorder [audioUrl]="item.guideAudioUrl2" id="guideAudioUrl2"
(audioUploaded)="onAudioUploadSuccess($event, item, 'guideAudioUrl2')">
</app-audio-recorder>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSpan]="2" nzFor="guideAudioUrl3">结束音频</nz-form-label>
<nz-form-control [nzSpan]="4">
<app-audio-recorder [audioUrl]="item.guideAudioUrl3" id="guideAudioUrl3"
(audioUploaded)="onAudioUploadSuccess($event, item, 'guideAudioUrl3')">
</app-audio-recorder>
</nz-form-control>
</nz-form-item>
<nz-form-item> <nz-form-item>
<nz-form-label [nzSpan]="2">图片</nz-form-label> <nz-form-label [nzSpan]="2">图片</nz-form-label>
<nz-form-control [nzSpan]="4"> <nz-form-control [nzSpan]="4">
...@@ -16,6 +40,14 @@ ...@@ -16,6 +40,14 @@
</app-upload-image-with-preview> </app-upload-image-with-preview>
</nz-form-control> </nz-form-control>
</nz-form-item> </nz-form-item>
<nz-form-item>
<nz-form-label [nzSpan]="2">图片音频</nz-form-label>
<nz-form-control [nzSpan]="4">
<app-audio-recorder [audioUrl]="item.audioUrl"
(audioUploaded)="onAudioUploadSuccess($event, item, 'audioUrl')">
</app-audio-recorder>
</nz-form-control>
</nz-form-item>
<nz-form-item> <nz-form-item>
<nz-form-label [nzSpan]="2" nzFor="add-btn">字母添加</nz-form-label> <nz-form-label [nzSpan]="2" nzFor="add-btn">字母添加</nz-form-label>
<nz-form-control [nzSpan]="4"> <nz-form-control [nzSpan]="4">
......
...@@ -86,14 +86,14 @@ ...@@ -86,14 +86,14 @@
], ],
"_active": true, "_active": true,
"_components": [ "_components": [
{
"__id__": 63
},
{ {
"__id__": 64 "__id__": 64
}, },
{ {
"__id__": 65 "__id__": 65
},
{
"__id__": 66
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -2618,7 +2618,7 @@ ...@@ -2618,7 +2618,7 @@
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 62 "__id__": 63
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -2684,7 +2684,7 @@ ...@@ -2684,7 +2684,7 @@
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 61 "__id__": 62
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -2742,11 +2742,15 @@ ...@@ -2742,11 +2742,15 @@
"_parent": { "_parent": {
"__id__": 58 "__id__": 58
}, },
"_children": [], "_children": [
{
"__id__": 60
}
],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 60 "__id__": 61
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -2797,6 +2801,64 @@ ...@@ -2797,6 +2801,64 @@
"groupIndex": 0, "groupIndex": 0,
"_id": "39olKLQahPUIkTaY3Gn6UZ" "_id": "39olKLQahPUIkTaY3Gn6UZ"
}, },
{
"__type__": "cc.Node",
"_name": "ClickBtn",
"_objFlags": 0,
"_parent": {
"__id__": 59
},
"_children": [],
"_active": true,
"_components": [],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 350,
"height": 480
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
897.519,
-511.586,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "0eB5hWS1pEMr5OgLpENfMC"
},
{ {
"__type__": "dragonBones.ArmatureDisplay", "__type__": "dragonBones.ArmatureDisplay",
"_name": "", "_name": "",
......
...@@ -119,6 +119,10 @@ cc.Class({ ...@@ -119,6 +119,10 @@ cc.Class({
} }
this._audioResList.push({ url: this.data.guideAudioUrl1 });
this._audioResList.push({ url: this.data.guideAudioUrl2 });
this._audioResList.push({ url: this.data.guideAudioUrl3 });
this._audioResList.push({ url: this.data.audioUrl });
}, },
addPreloadAnima() { addPreloadAnima() {
...@@ -199,26 +203,35 @@ cc.Class({ ...@@ -199,26 +203,35 @@ cc.Class({
handNode.initY = handNode.y; handNode.initY = handNode.y;
//播放动车
this.playAni('begin', 0);
const begin = () => { const begin = () => {
this.playAni('normal', 0); this.playAni('normal', 0);
//移动手指位置 //移动手指位置
this.moveHand(this._curIndex, () => { this.moveHand(this._curIndex, () => {
this._cantouch = true; this._cantouch = true;
}); });
this._canClickCat = true;
} }
//如果有引导音频,则播放完引导音频再开始 //如果有引导音频,则播放完引导音频再开始
if (this.data.guideAudioUrl1) { if (this.data.guideAudioUrl1) {
//播放开始动画
const state = this.playAni('begin', 0);
//播放引导音频1 //播放引导音频1
this.playAudioByUrl(this.data.guideAudioUrl1, () => { this.playAudioByUrl(this.data.guideAudioUrl1, () => {
state.stop();
begin(); begin();
}); });
} }
else { else {
begin(); this.playAni('begin', 1, () => {
begin();
})
} }
this.addDefaultMusic(); this.addDefaultMusic();
...@@ -308,10 +321,120 @@ cc.Class({ ...@@ -308,10 +321,120 @@ cc.Class({
this._curIndex = 0; this._curIndex = 0;
}, },
_canClickCat: null,
_showStandby: null,
initBtn() { initBtn() {
const catBtn = cc.find('Canvas/Main Camera/catFrame/cat/ClickBtn');
catBtn.addComponent(cc.Button);
catBtn.on('click', () => {
if(!this._cantouch){
return;
}
if(!this._canClickCat){
return;
}
if(this._showStandby){
return;
}
this._showStandby = true;
//播放待机音频
if(this.data.guideAudioUrl2){
const state = this.playAni('begin', 0);
//播放完成,停止动画
this.playAudioByUrl(this.data.guideAudioUrl2, () => {
state.stop();
this._showStandby = false;
this.playAni('normal', 0);
});
}
else{
this.playAni('begin', 1, () => {
this._showStandby = false;
});
}
});
let textNode = cc.find("Canvas/content/bg_green/bg_word-background/text");
let wordNodeArr = textNode.wordNodeArr;
let handNode = cc.find("Canvas/content/bg_green/bg_word-background/text/icon_hand");
handNode.addComponent(cc.Button);
handNode.on('click', () => {
if(!this._cantouch){
return;
}
let wordNode = wordNodeArr[2 * index];
this.playTextAutio(wordNode, wordNode.data.lrcData.audio_url, () => {
this._cantouch = true;
})
});
const picNode = cc.find("Canvas/content/bg_green/pic");
picNode.addComponent(cc.Button);
picNode.on('click', () => {
if(!this._cantouch){
return;
}
this._cantouch = false;
let rotation = picNode.angle;
let times = 1;
const rota = () => {
cc.tween(picNode)
.to(0.3, { angle: rotation - 15 })
.to(0.3, { angle: rotation })
.to(0.3, { angle: rotation + 15 })
.to(0.3, { angle: rotation })
.call(() => {
if(times > 2){
this._cantouch = true;
return;
}
times += 1;
rota();
})
.start();
}
console.log("click pic...");
if(this.data.audioUrl){
const state = this.playAni('begin', 0);
this.playAudioByUrl(this.data.audioUrl, ()=>{
state.stop();
//播放待机
this.playAni("normal", 0);
});
}
rota();
});
}, },
getWord(word, wordVal, size, isInitial) { getWord(word, wordVal, size, isInitial) {
...@@ -349,26 +472,16 @@ cc.Class({ ...@@ -349,26 +472,16 @@ cc.Class({
let audioUrl = word.lrcData.audio_url; let audioUrl = word.lrcData.audio_url;
//如果是首字母,则添加点击事件 //显示完,则播放音频
if (isInitial) { if (this._shown) {
this.playTextAutio(labelNode, audioUrl, () => { this.playTextAutio(labelNode, audioUrl, () => {
this._cantouch = true; this._cantouch = true;
}) });
} }
else { else {
//显示完,则播放音频 this._cantouch = true;
if (this._shown) {
this.playTextAutio(labelNode, audioUrl, () => {
this._cantouch = true;
});
}
else {
this._cantouch = true;
}
} }
}) })
}) })
...@@ -397,13 +510,29 @@ cc.Class({ ...@@ -397,13 +510,29 @@ cc.Class({
}, },
playAni(name, times = 1) { catAniState: null,
playAni(name, times = 1, cb = null) {
if(this.catAniState && this.catAniState.name != name)
{
this.catAniState.stop();
}
const cat = cc.find('Canvas/Main Camera/catFrame/cat'); const cat = cc.find('Canvas/Main Camera/catFrame/cat');
var dragonDisplay = cat.getComponent(dragonBones.ArmatureDisplay); var dragonDisplay = cat.getComponent(dragonBones.ArmatureDisplay);
const state = dragonDisplay.playAnimation(name, times); const state = dragonDisplay.playAnimation(name, times);
dragonDisplay.on(dragonBones.EventObject.COMPLETE, () => {
tip.active = false;
if (cb) {
cb();
}
})
this.catAniState = state;
return state; return state;
}, },
...@@ -442,6 +571,8 @@ cc.Class({ ...@@ -442,6 +571,8 @@ cc.Class({
*/ */
playTextAutio(labelNode, audioUrl, callback = null) { playTextAutio(labelNode, audioUrl, callback = null) {
const state = this.playAni('begin', 0);
this.playAudioByUrl(audioUrl, () => { this.playAudioByUrl(audioUrl, () => {
//停止监听动画 //停止监听动画
...@@ -449,6 +580,11 @@ cc.Class({ ...@@ -449,6 +580,11 @@ cc.Class({
this._cantouch = true; this._cantouch = true;
state.stop();
//播放待机动画
this.playAni('normal', 0);
this._curIndex++; this._curIndex++;
this.moveHand(this._curIndex, () => { this.moveHand(this._curIndex, () => {
this._cantouch = true; this._cantouch = true;
...@@ -480,19 +616,6 @@ cc.Class({ ...@@ -480,19 +616,6 @@ cc.Class({
console.log(arr); console.log(arr);
this.monitor(labelNode, audioId, arr); this.monitor(labelNode, audioId, arr);
/*
this.textTwinkle(labelNode, () => {
this._cantouch = true;
this._curIndex++;
this.moveHand(this._curIndex, () => {
this._cantouch = true;
this.showEnd();
})
});
*/
}) })
}, },
...@@ -571,6 +694,15 @@ cc.Class({ ...@@ -571,6 +694,15 @@ cc.Class({
handNode.opacity = 0; handNode.opacity = 0;
this._stop = true; this._stop = true;
if(this.data.guideAudioUrl3){
const state = this.playAni('finish', 0);
this.playAudioByUrl(this.data.guideAudioUrl3, () => {
state.stop();
this.playAni('normal', 0);
})
}
}, },
_stop: null, _stop: null,
...@@ -676,6 +808,7 @@ cc.Class({ ...@@ -676,6 +808,7 @@ cc.Class({
/** /**
* 内容动画 * 内容动画
*/ */
_times:null,
contentAni() { contentAni() {
let handNode = cc.find("Canvas/content/bg_green/bg_word-background/text/icon_hand"); let handNode = cc.find("Canvas/content/bg_green/bg_word-background/text/icon_hand");
...@@ -689,8 +822,19 @@ cc.Class({ ...@@ -689,8 +822,19 @@ cc.Class({
.to(0.5, { scale: node.initScale }) .to(0.5, { scale: node.initScale })
.call(() => { .call(() => {
this._cantouch = true; this._cantouch = true;
if(this._shown){
return;
}
this._curIndex++; this._curIndex++;
if(this._curIndex >= this.data.exercises.wordArr.length && !this._times){
this._times = 1;
this._curIndex = 0;
console.log("the first time");
}
this.moveHand(this._curIndex, () => { this.moveHand(this._curIndex, () => {
this._cantouch = true; this._cantouch = true;
......
...@@ -54,7 +54,11 @@ export const defaultData = { ...@@ -54,7 +54,11 @@ export const defaultData = {
], ],
"picUrl":"http://staging-teach.cdn.ireadabc.com/101cdabba6404b73292d3b676f4683b1.png", "picUrl":"http://staging-teach.cdn.ireadabc.com/101cdabba6404b73292d3b676f4683b1.png",
"audioUrl":"http://staging-teach.cdn.ireadabc.com/bbab99eb9f5fe3cbe2d24cf80594d8c9.mp3" "audioUrl":"http://staging-teach.cdn.ireadabc.com/bbab99eb9f5fe3cbe2d24cf80594d8c9.mp3"
} },
"audioUrl":"http://staging-teach.cdn.ireadabc.com/bbab99eb9f5fe3cbe2d24cf80594d8c9.mp3",
"guideAudioUrl1":"http://staging-teach.cdn.ireadabc.com/c3b83a24fd8f9b37ee72409cdb45e3f7.mp3",
"guideAudioUrl2":"http://staging-teach.cdn.ireadabc.com/9f6ff5d0617bf274ee2d9af4cfc93c62.mp3",
"guideAudioUrl3":"http://staging-teach.cdn.ireadabc.com/c3b83a24fd8f9b37ee72409cdb45e3f7.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