Commit 1f2d842a authored by Tt's avatar Tt

增加音效点击效果

parent 936126a2
...@@ -45,7 +45,7 @@ export default class ImgVoice extends cc.Component { ...@@ -45,7 +45,7 @@ export default class ImgVoice extends cc.Component {
this.playVoiceCount = 0; this.playVoiceCount = 0;
let list = this.node.children; let list = this.node.children;
list.forEach((li, i) => { list.forEach((li, i) => {
li.active = false li.active = i == 0
}) })
} }
} }
......
...@@ -2056,13 +2056,13 @@ ...@@ -2056,13 +2056,13 @@
}, },
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "icon_vioce1", "_name": "icon_vioce3",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 41 "__id__": 41
}, },
"_children": [], "_children": [],
"_active": true, "_active": false,
"_components": [ "_components": [
{ {
"__id__": 43 "__id__": 43
...@@ -2114,7 +2114,7 @@ ...@@ -2114,7 +2114,7 @@
"_is3DNode": false, "_is3DNode": false,
"_groupIndex": 0, "_groupIndex": 0,
"groupIndex": 0, "groupIndex": 0,
"_id": "bbPjdnqJFDrprJoheRfwmk" "_id": "501OBejCFGAazbX9641Glz"
}, },
{ {
"__type__": "cc.Sprite", "__type__": "cc.Sprite",
...@@ -2132,7 +2132,7 @@ ...@@ -2132,7 +2132,7 @@
"_srcBlendFactor": 770, "_srcBlendFactor": 770,
"_dstBlendFactor": 771, "_dstBlendFactor": 771,
"_spriteFrame": { "_spriteFrame": {
"__uuid__": "43b29bb7-6f39-4b2f-ad57-012c9666d70e" "__uuid__": "c3c12d3b-e370-413a-acca-565a10fa453a"
}, },
"_type": 0, "_type": 0,
"_sizeMode": 1, "_sizeMode": 1,
...@@ -2146,7 +2146,7 @@ ...@@ -2146,7 +2146,7 @@
"_fillRange": 0, "_fillRange": 0,
"_isTrimmedMode": true, "_isTrimmedMode": true,
"_atlas": null, "_atlas": null,
"_id": "1elU3fpixGNbe9Hm8ZzlP2" "_id": "2dG9LKzvdEVrr5pG8l8Tkb"
}, },
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
...@@ -2156,7 +2156,7 @@ ...@@ -2156,7 +2156,7 @@
"__id__": 41 "__id__": 41
}, },
"_children": [], "_children": [],
"_active": true, "_active": false,
"_components": [ "_components": [
{ {
"__id__": 45 "__id__": 45
...@@ -2244,13 +2244,13 @@ ...@@ -2244,13 +2244,13 @@
}, },
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "icon_vioce3", "_name": "icon_vioce1",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 41 "__id__": 41
}, },
"_children": [], "_children": [],
"_active": true, "_active": false,
"_components": [ "_components": [
{ {
"__id__": 47 "__id__": 47
...@@ -2302,7 +2302,7 @@ ...@@ -2302,7 +2302,7 @@
"_is3DNode": false, "_is3DNode": false,
"_groupIndex": 0, "_groupIndex": 0,
"groupIndex": 0, "groupIndex": 0,
"_id": "501OBejCFGAazbX9641Glz" "_id": "bbPjdnqJFDrprJoheRfwmk"
}, },
{ {
"__type__": "cc.Sprite", "__type__": "cc.Sprite",
...@@ -2320,7 +2320,7 @@ ...@@ -2320,7 +2320,7 @@
"_srcBlendFactor": 770, "_srcBlendFactor": 770,
"_dstBlendFactor": 771, "_dstBlendFactor": 771,
"_spriteFrame": { "_spriteFrame": {
"__uuid__": "c3c12d3b-e370-413a-acca-565a10fa453a" "__uuid__": "43b29bb7-6f39-4b2f-ad57-012c9666d70e"
}, },
"_type": 0, "_type": 0,
"_sizeMode": 1, "_sizeMode": 1,
...@@ -2334,7 +2334,7 @@ ...@@ -2334,7 +2334,7 @@
"_fillRange": 0, "_fillRange": 0,
"_isTrimmedMode": true, "_isTrimmedMode": true,
"_atlas": null, "_atlas": null,
"_id": "2dG9LKzvdEVrr5pG8l8Tkb" "_id": "1elU3fpixGNbe9Hm8ZzlP2"
}, },
{ {
"__type__": "cc.Widget", "__type__": "cc.Widget",
...@@ -3390,6 +3390,9 @@ ...@@ -3390,6 +3390,9 @@
"__id__": 2 "__id__": 2
}, },
"_enabled": true, "_enabled": true,
"btn_voice": {
"__id__": 41
},
"_id": "eaTVUpqahPfZeO9+sUI7RP" "_id": "eaTVUpqahPfZeO9+sUI7RP"
} }
] ]
\ No newline at end of file
...@@ -56,6 +56,23 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -56,6 +56,23 @@ export default class SceneComponent extends MyCocosSceneComponent {
} }
initView() { } initView() { }
initEvent() { initEvent() {
pg.view.touchOn(this.btn_voice, this.onTouchVoice, this);
}
private audioId: any;
onTouchVoice() {
if (!this.canTouch) return;
if (this.audioId) {
cc.audioEngine.stopEffect(this.audioId);
this.btn_voice.getComponent(ImgVoice).playVoiceEnd();
}
this.btn_voice.getComponent(ImgVoice).playVoiceStart();
pg.audio.playAudioByUrl(this.currentQuestion.questionAudio, () => {
this.audioId = null;
this.btn_voice.getComponent(ImgVoice).playVoiceEnd();
this.startCreate = true;
}, audioId => {
this.audioId = audioId;
})
} }
resetView() { }; resetView() { };
...@@ -121,13 +138,17 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -121,13 +138,17 @@ export default class SceneComponent extends MyCocosSceneComponent {
pg.view.find(this, 'layer_game/layer_paopao').removeAllChildren(); pg.view.find(this, 'layer_game/layer_paopao').removeAllChildren();
this.startQuestion(); this.startQuestion();
this.btn_voice.getComponent(ImgVoice).playVoiceStart();
pg.audio.playAudioByUrl(this.currentQuestion.questionAudio).then(() => { pg.audio.playAudioByUrl(this.currentQuestion.questionAudio).then(() => {
this.btn_voice.getComponent(ImgVoice).playVoiceEnd();
this.startCreate = true; this.startCreate = true;
pg.hw.playLocalAudio('countdown', true).then((id) => { // pg.hw.playLocalAudio('countdown', true).then((id) => {
this.loopId = id; // this.loopId = id;
}) // })
}) })
} }
@property(cc.Node)
private btn_voice: cc.Node = null;
private loopId: any; private loopId: any;
// 制造气泡 // 制造气泡
private canTouch: boolean; private canTouch: boolean;
......
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