Commit 7159b3e8 authored by yu's avatar yu

背景音乐

parent c50b5fbe
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
"height": 162, "height": 162,
"platformSettings": {}, "platformSettings": {},
"subMetas": { "subMetas": {
"1": { "1_duiduipeng": {
"ver": "1.0.4", "ver": "1.0.4",
"uuid": "64239ea1-64ac-4b1d-a057-c1aef63daa78", "uuid": "64239ea1-64ac-4b1d-a057-c1aef63daa78",
"rawTextureUuid": "104fcdb0-ca93-48e9-851a-7be61991ae7d", "rawTextureUuid": "104fcdb0-ca93-48e9-851a-7be61991ae7d",
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
"height": 162, "height": 162,
"platformSettings": {}, "platformSettings": {},
"subMetas": { "subMetas": {
"2": { "2_duiduipeng": {
"ver": "1.0.4", "ver": "1.0.4",
"uuid": "5947b8ea-32dd-4bdf-96b1-c0a3f4078b54", "uuid": "5947b8ea-32dd-4bdf-96b1-c0a3f4078b54",
"rawTextureUuid": "694a16fe-9586-4971-b69b-770579e00c12", "rawTextureUuid": "694a16fe-9586-4971-b69b-770579e00c12",
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
"height": 162, "height": 162,
"platformSettings": {}, "platformSettings": {},
"subMetas": { "subMetas": {
"3": { "3_duiduipeng": {
"ver": "1.0.4", "ver": "1.0.4",
"uuid": "393041ff-00e2-4ef3-97be-82e57154cfc9", "uuid": "393041ff-00e2-4ef3-97be-82e57154cfc9",
"rawTextureUuid": "b85f7d46-90f8-4112-8e92-bde93c1ebfe1", "rawTextureUuid": "b85f7d46-90f8-4112-8e92-bde93c1ebfe1",
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
"height": 750, "height": 750,
"platformSettings": {}, "platformSettings": {},
"subMetas": { "subMetas": {
"bg_1": { "bg_1_duiduipeng": {
"ver": "1.0.4", "ver": "1.0.4",
"uuid": "4d2e721d-5a99-4895-b29c-1365abc2e99b", "uuid": "4d2e721d-5a99-4895-b29c-1365abc2e99b",
"rawTextureUuid": "d215adad-1d8d-4af6-89e2-0611bd733c09", "rawTextureUuid": "d215adad-1d8d-4af6-89e2-0611bd733c09",
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
"height": 750, "height": 750,
"platformSettings": {}, "platformSettings": {},
"subMetas": { "subMetas": {
"bg_2": { "bg_2_duiduipeng": {
"ver": "1.0.4", "ver": "1.0.4",
"uuid": "8598ba9d-9fd3-45ee-9acb-6b9d4a3326b7", "uuid": "8598ba9d-9fd3-45ee-9acb-6b9d4a3326b7",
"rawTextureUuid": "c3527267-be17-4637-8d72-0491d613645e", "rawTextureUuid": "c3527267-be17-4637-8d72-0491d613645e",
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
"height": 275, "height": 275,
"platformSettings": {}, "platformSettings": {},
"subMetas": { "subMetas": {
"bg_card": { "bg_card_duiduipeng": {
"ver": "1.0.4", "ver": "1.0.4",
"uuid": "56034c3a-b8d7-4338-a610-baaf46c7ff07", "uuid": "56034c3a-b8d7-4338-a610-baaf46c7ff07",
"rawTextureUuid": "19d921cf-2185-4abc-b361-46fb632246f8", "rawTextureUuid": "19d921cf-2185-4abc-b361-46fb632246f8",
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
"height": 275, "height": 275,
"platformSettings": {}, "platformSettings": {},
"subMetas": { "subMetas": {
"bg_crad-back": { "bg_cradback_duiduipeng": {
"ver": "1.0.4", "ver": "1.0.4",
"uuid": "8cf59de8-161c-49b0-839a-5c75d8fe1f62", "uuid": "8cf59de8-161c-49b0-839a-5c75d8fe1f62",
"rawTextureUuid": "9b8e2f51-fecc-427e-bc08-e038341cd7ff", "rawTextureUuid": "9b8e2f51-fecc-427e-bc08-e038341cd7ff",
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
"height": 78, "height": 78,
"platformSettings": {}, "platformSettings": {},
"subMetas": { "subMetas": {
"bg_left": { "bg_left_duiduipeng": {
"ver": "1.0.4", "ver": "1.0.4",
"uuid": "9728aa40-7608-46bd-888e-2acd417225bb", "uuid": "9728aa40-7608-46bd-888e-2acd417225bb",
"rawTextureUuid": "fdf0607a-8226-4f0f-b65c-0efa428dec03", "rawTextureUuid": "fdf0607a-8226-4f0f-b65c-0efa428dec03",
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
"height": 192, "height": 192,
"platformSettings": {}, "platformSettings": {},
"subMetas": { "subMetas": {
"bg_right": { "bg_right_duiduipeng": {
"ver": "1.0.4", "ver": "1.0.4",
"uuid": "ea953cb1-9e26-4c90-b9cf-6d8ecdce2161", "uuid": "ea953cb1-9e26-4c90-b9cf-6d8ecdce2161",
"rawTextureUuid": "a2e277a2-fc5f-4619-b7ed-97683f510604", "rawTextureUuid": "a2e277a2-fc5f-4619-b7ed-97683f510604",
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
"height": 162, "height": 162,
"platformSettings": {}, "platformSettings": {},
"subMetas": { "subMetas": {
"bg_time2": { "bg_time2_duiduipeng": {
"ver": "1.0.4", "ver": "1.0.4",
"uuid": "276627a2-ebed-4885-8308-1433ebfb24f5", "uuid": "276627a2-ebed-4885-8308-1433ebfb24f5",
"rawTextureUuid": "fbf7af93-3cd7-433c-ab0e-3a79c68cdc2c", "rawTextureUuid": "fbf7af93-3cd7-433c-ab0e-3a79c68cdc2c",
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
"height": 162, "height": 162,
"platformSettings": {}, "platformSettings": {},
"subMetas": { "subMetas": {
"bg_time": { "bg_time_duiduipeng": {
"ver": "1.0.4", "ver": "1.0.4",
"uuid": "6c68d460-fc18-4991-b61e-1a32a77efa1f", "uuid": "6c68d460-fc18-4991-b61e-1a32a77efa1f",
"rawTextureUuid": "b3a18e7c-4c9c-4616-b49a-173ffa4b72d2", "rawTextureUuid": "b3a18e7c-4c9c-4616-b49a-173ffa4b72d2",
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
"height": 370, "height": 370,
"platformSettings": {}, "platformSettings": {},
"subMetas": { "subMetas": {
"bg_tip": { "bg_tip_duiduipeng": {
"ver": "1.0.4", "ver": "1.0.4",
"uuid": "a92f202f-40e1-4967-bcfd-7c67b36c5230", "uuid": "a92f202f-40e1-4967-bcfd-7c67b36c5230",
"rawTextureUuid": "1db0f660-34e5-4b4c-818f-5ba92b188376", "rawTextureUuid": "1db0f660-34e5-4b4c-818f-5ba92b188376",
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
"height": 111, "height": 111,
"platformSettings": {}, "platformSettings": {},
"subMetas": { "subMetas": {
"bg_title": { "bg_title_duiduipeng": {
"ver": "1.0.4", "ver": "1.0.4",
"uuid": "f32598ac-4a6f-4e3b-a2d5-5804f656ce1e", "uuid": "f32598ac-4a6f-4e3b-a2d5-5804f656ce1e",
"rawTextureUuid": "d1cbff37-a335-4eb1-b69f-f77e46378e02", "rawTextureUuid": "d1cbff37-a335-4eb1-b69f-f77e46378e02",
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
"height": 100, "height": 100,
"platformSettings": {}, "platformSettings": {},
"subMetas": { "subMetas": {
"btn_restart": { "btn_restart_duiduipeng": {
"ver": "1.0.4", "ver": "1.0.4",
"uuid": "f3c5c29c-c7b3-4110-9d49-307e08d42533", "uuid": "f3c5c29c-c7b3-4110-9d49-307e08d42533",
"rawTextureUuid": "bfdbe139-512d-4dff-a3b2-4345fbd47080", "rawTextureUuid": "bfdbe139-512d-4dff-a3b2-4345fbd47080",
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
"height": 100, "height": 100,
"platformSettings": {}, "platformSettings": {},
"subMetas": { "subMetas": {
"btn_start": { "btn_start_duiduipeng": {
"ver": "1.0.4", "ver": "1.0.4",
"uuid": "4af2db97-1221-45e8-9267-c6d1d456a356", "uuid": "4af2db97-1221-45e8-9267-c6d1d456a356",
"rawTextureUuid": "eb530758-88e8-4c23-b00d-45c6ebddd4f6", "rawTextureUuid": "eb530758-88e8-4c23-b00d-45c6ebddd4f6",
......
{
"ver": "2.3.5",
"uuid": "f2cf16e7-c43f-41a8-b4c9-573595d4f00b",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 78,
"height": 124,
"platformSettings": {},
"subMetas": {
"ddp_bg_audio_off_duiduipeng": {
"ver": "1.0.4",
"uuid": "f3d29815-dbef-4d4d-bc96-4a0205ec634e",
"rawTextureUuid": "f2cf16e7-c43f-41a8-b4c9-573595d4f00b",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 78,
"height": 124,
"rawWidth": 78,
"rawHeight": 124,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "b97d9afb-7320-44fe-8112-3d565dab3b8a",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 78,
"height": 124,
"platformSettings": {},
"subMetas": {
"ddp_bg_audio_on_duiduipeng": {
"ver": "1.0.4",
"uuid": "fd4221f7-0062-4873-9668-184181e30506",
"rawTextureUuid": "b97d9afb-7320-44fe-8112-3d565dab3b8a",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 78,
"height": 124,
"rawWidth": 78,
"rawHeight": 124,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
...@@ -154,3 +154,4 @@ export default class card extends cc.Component { ...@@ -154,3 +154,4 @@ export default class card extends cc.Component {
// update (dt) {} // update (dt) {}
} }
This diff is collapsed.
import { asyncDelay, onHomeworkFinish } from "../script/util"; import { asyncDelay, onHomeworkFinish } from "../script/util_duiduipeng";
import { MyCocosSceneComponent } from "../script/MyCocosSceneComponent"; import { MyCocosSceneComponent } from "../script/MyCocosSceneComponent_duiduipeng";
const { ccclass, property } = cc._decorator; const { ccclass, property } = cc._decorator;
...@@ -17,6 +17,15 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -17,6 +17,15 @@ export default class SceneComponent extends MyCocosSceneComponent {
tipN: cc.Node = null tipN: cc.Node = null
@property(cc.Node) @property(cc.Node)
countDown: cc.Node = null; countDown: cc.Node = null;
@property(cc.Node)
btn_audio_off: cc.Node = null;
@property(cc.Node)
btn_audio_on: cc.Node = null;
private isPlayBgAudio: boolean;
questionIndex = 0; questionIndex = 0;
gameState = "watching" gameState = "watching"
watchInterval = null; watchInterval = null;
...@@ -51,6 +60,8 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -51,6 +60,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
addPreloadAudio() { addPreloadAudio() {
// TODO 根据自己的配置预加载音频资源 // TODO 根据自己的配置预加载音频资源
// this._audioResList.push({ url: this.data.audio_url }); // this._audioResList.push({ url: this.data.audio_url });
this._audioResList.push({ url: this.data.bgAudio });
this._audioResList.push({ url: this.data.questionTextAudio });
} }
addPreloadAnima() { addPreloadAnima() {
...@@ -84,7 +95,33 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -84,7 +95,33 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.tipLabel.string = this.data.questionText; this.tipLabel.string = this.data.questionText;
this.initCards() this.initCards()
this.initTime(); this.initTime();
if (this.data.bgAudio && this.data.bgAudio != "") {
this.btn_audio_on.active = true;
}
this.btn_audio_off.on(cc.Node.EventType.TOUCH_END, this.onAudioOff, this);
this.btn_audio_on.on(cc.Node.EventType.TOUCH_END, this.onAudioOn, this);
} }
private onAudioOn() {
this.btn_audio_off.active = true;
this.btn_audio_on.active = false;
this.isPlayBgAudio = false;
this.stopBgAudio();
}
private onAudioOff() {
this.btn_audio_on.active = true;
this.btn_audio_off.active = false;
this.isPlayBgAudio = true;
this.playBgAudio();
}
private playBgAudio() {
if (!this.isPlayBgAudio) return;
cc.audioEngine.resumeMusic();
}
private stopBgAudio() {
cc.audioEngine.pauseMusic();
}
initGameData(){ initGameData(){
this.clickNode1 = null; this.clickNode1 = null;
this.clickNodeData1 = null this.clickNodeData1 = null
...@@ -118,7 +155,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -118,7 +155,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
} else { } else {
card.y = +card.height / 2 + 10 card.y = +card.height / 2 + 10
} }
card.getComponent("card").initData(data[i], this) card.getComponent("card_duiduipeng").initData(data[i], this)
} }
} else if (col == 2) { } else if (col == 2) {
...@@ -137,7 +174,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -137,7 +174,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
} else { } else {
card.y = +card.height / 2 + 10 card.y = +card.height / 2 + 10
} }
card.getComponent("card").initData(data[i], this) card.getComponent("card_duiduipeng").initData(data[i], this)
} }
} else { } else {
...@@ -150,7 +187,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -150,7 +187,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
} else { } else {
card.y = +card.height / 2 + 10 card.y = +card.height / 2 + 10
} }
card.getComponent("card").initData(data[i], this) card.getComponent("card_duiduipeng").initData(data[i], this)
} }
} }
console.log(" this.cardParentN=====", this.cardParentN) console.log(" this.cardParentN=====", this.cardParentN)
...@@ -232,9 +269,10 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -232,9 +269,10 @@ export default class SceneComponent extends MyCocosSceneComponent {
onStartClick() { onStartClick() {
this.tipN.active = false; this.tipN.active = false;
this.playLocalAudio("btn"); this.playLocalAudio("btn");
this.playBgAudioByUrl(this.data.bgAudio);
let children = this.cardParentN.children; let children = this.cardParentN.children;
for (let i = 0; i < children.length; i++) { for (let i = 0; i < children.length; i++) {
children[i].getComponent("card").asyncDoFlip(() => { children[i].getComponent("card_duiduipeng").asyncDoFlip(() => {
if (i == children.length - 1) this.startWatch(); if (i == children.length - 1) this.startWatch();
}) })
} }
...@@ -252,7 +290,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -252,7 +290,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.clearntervals(); this.clearntervals();
let children = this.cardParentN.children; let children = this.cardParentN.children;
for (let i = 0; i < children.length; i++) { for (let i = 0; i < children.length; i++) {
children[i].getComponent("card").asyncDoFlip(() => { children[i].getComponent("card_duiduipeng").asyncDoFlip(() => {
if (i == children.length - 1) this.startGame(); if (i == children.length - 1) this.startGame();
}) })
} }
...@@ -294,7 +332,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -294,7 +332,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
if (!this.clickNode1) { if (!this.clickNode1) {
this.clickNode1 = node; this.clickNode1 = node;
this.clickNodeData1 = data; this.clickNodeData1 = data;
this.clickNode1.getComponent("card").asyncDoFlip() this.clickNode1.getComponent("card_duiduipeng").asyncDoFlip()
this.asyncPlayAudioByUrl(this.clickNodeData1.audio); this.asyncPlayAudioByUrl(this.clickNodeData1.audio);
// this.asyncPlayAudioByUrl( this.data.questionTextAudio); // this.asyncPlayAudioByUrl( this.data.questionTextAudio);
...@@ -307,12 +345,12 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -307,12 +345,12 @@ export default class SceneComponent extends MyCocosSceneComponent {
if (this.clickNodeData1.pairIdx == data.pairIdx) { if (this.clickNodeData1.pairIdx == data.pairIdx) {
// this.asyncPlayAudioByUrl(data.audio) // this.asyncPlayAudioByUrl(data.audio)
Promise Promise
.all([node.getComponent("card").asyncDoFlip(), this.asyncPlayAudioByUrl(data.audio)]) .all([node.getComponent("card_duiduipeng").asyncDoFlip(), this.asyncPlayAudioByUrl(data.audio)])
.then(() => { .then(() => {
this.playLocalAudio("true") this.playLocalAudio("true")
Promise.all([node.getComponent("card").playDragon(), this.clickNode1.getComponent("card").playDragon()]) Promise.all([node.getComponent("card_duiduipeng").playDragon(), this.clickNode1.getComponent("card_duiduipeng").playDragon()])
.then(() => { .then(() => {
Promise.all([node.getComponent("card").doHide(), this.clickNode1.getComponent("card").doHide()]) Promise.all([node.getComponent("card_duiduipeng").doHide(), this.clickNode1.getComponent("card_duiduipeng").doHide()])
.then(() => { .then(() => {
this.canTouch = true; this.canTouch = true;
this.clickNode1 = null this.clickNode1 = null
...@@ -340,12 +378,12 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -340,12 +378,12 @@ export default class SceneComponent extends MyCocosSceneComponent {
) )
} else { } else {
Promise Promise
.all([node.getComponent("card").asyncDoFlip(), this.asyncPlayAudioByUrl(data.audio)]) .all([node.getComponent("card_duiduipeng").asyncDoFlip(), this.asyncPlayAudioByUrl(data.audio)])
.then(() => { .then(() => {
this.playLocalAudio("false") this.playLocalAudio("false")
// Promise.all([this.playLocalAudio("false")]) // Promise.all([this.playLocalAudio("false")])
// .then(() => { // .then(() => {
Promise.all([node.getComponent("card").asyncDoFlip(), this.clickNode1.getComponent("card").asyncDoFlip()]) Promise.all([node.getComponent("card_duiduipeng").asyncDoFlip(), this.clickNode1.getComponent("card_duiduipeng").asyncDoFlip()])
.then(() => { .then(() => {
this.canTouch = true; this.canTouch = true;
this.clickNode1 = null this.clickNode1 = null
...@@ -371,7 +409,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -371,7 +409,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.tipN.active = false; this.tipN.active = false;
let children = this.cardParentN.children; let children = this.cardParentN.children;
for (let i = 0; i < children.length; i++) { for (let i = 0; i < children.length; i++) {
children[i].getComponent("card").asyncDoFlip(() => { children[i].getComponent("card_duiduipeng").asyncDoFlip(() => {
if (i == children.length - 1) this.startWatch(); if (i == children.length - 1) this.startWatch();
}) })
} }
...@@ -403,7 +441,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -403,7 +441,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
playLocalAudio(audioName,stopAll=true) { playLocalAudio(audioName,stopAll=true) {
const audio = cc.find(`Canvas/res/audio/${audioName}`).getComponent(cc.AudioSource); const audio = cc.find(`Canvas/res/audio/${audioName}`).getComponent(cc.AudioSource);
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if(stopAll) cc.audioEngine.stopAll(); // if(stopAll) cc.audioEngine.stopAll();
const id = cc.audioEngine.playEffect(audio.clip, false); const id = cc.audioEngine.playEffect(audio.clip, false);
cc.audioEngine.setFinishCallback(id, () => { cc.audioEngine.setFinishCallback(id, () => {
...@@ -497,3 +535,4 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -497,3 +535,4 @@ export default class SceneComponent extends MyCocosSceneComponent {
// } // }
} }
import { defaultData } from "../script/defaultData"; import { defaultData } from "../script/defaultData_duiduipeng";
export class MyCocosSceneComponent extends cc.Component { export class MyCocosSceneComponent extends cc.Component {
...@@ -179,7 +179,7 @@ export class MyCocosSceneComponent extends cc.Component { ...@@ -179,7 +179,7 @@ export class MyCocosSceneComponent extends cc.Component {
return new Promise((resole, reject) => { return new Promise((resole, reject) => {
cc.assetManager.loadRemote(audio_url, (err, audioClip) => { cc.assetManager.loadRemote(audio_url, (err, audioClip) => {
if(audioClip){ if(audioClip){
cc.audioEngine.stopAll(); // cc.audioEngine.stopAll();
const audioId = cc.audioEngine.play(audioClip, false, 0.8); const audioId = cc.audioEngine.play(audioClip, false, 0.8);
cc.audioEngine.setFinishCallback(audioId, () => { cc.audioEngine.setFinishCallback(audioId, () => {
if(cb)cb(); if(cb)cb();
...@@ -199,4 +199,37 @@ export class MyCocosSceneComponent extends cc.Component { ...@@ -199,4 +199,37 @@ export class MyCocosSceneComponent extends cc.Component {
return Promise.resolve(); return Promise.resolve();
} }
} }
}
\ No newline at end of file playBgAudioByUrl(audio_url, cb = null, loadCb = null) {
return new Promise((resolve, reject) => {
if (!audio_url) return resolve(null);
cc.assetManager.loadRemote(audio_url, (err, audioClip: any) => {
const audioId = cc.audioEngine.playMusic(audioClip, true);
cc.audioEngine.setFinishCallback(audioId, () => {
cb && cb();
});
loadCb && loadCb(audioId);
resolve(audioId);
});
});
}
playAudioByUrl(audio_url, cb = null) {
return new Promise((resolve, reject) => {
if (!audio_url) return resolve(null);
cc.assetManager.loadRemote(audio_url, (err, audioClip: any) => {
const audioId = cc.audioEngine.play(audioClip, false, 0.8);
cc.audioEngine.setFinishCallback(audioId, () => {
cb && cb(audioId);
});
resolve(audioId);
});
});
}
stopAudio(audioId) {
if (audioId < 0) return;
cc.audioEngine.stopEffect(audioId);
}
}
...@@ -2,6 +2,7 @@ export const defaultData = { ...@@ -2,6 +2,7 @@ export const defaultData = {
title: "标题标题", title: "标题标题",
questionText: "题目说明题目说明题目说明题目说明题目说明题目说明题目说明", questionText: "题目说明题目说明题目说明题目说明题目说明题目说明题目说明",
questionTextAudio: "http://staging-teach.cdn.ireadabc.com/92ddbc65e9af775f7a8450a5bef1a732.mp3", questionTextAudio: "http://staging-teach.cdn.ireadabc.com/92ddbc65e9af775f7a8450a5bef1a732.mp3",
"bgAudio": "https://staging-teach.cdn.ireadabc.com/ed84c18cc5f696ceaaf488ff98c228fe_l.mp3",
questions: [{ questions: [{
watchTime: 5, // 看题时间(秒) watchTime: 5, // 看题时间(秒)
gameTime: 10, // 游戏时间(秒) gameTime: 10, // 游戏时间(秒)
...@@ -165,4 +166,4 @@ export const defaultData = { ...@@ -165,4 +166,4 @@ export const defaultData = {
type: "img" type: "img"
}] }]
}] }]
} }
\ No newline at end of file
...@@ -418,4 +418,4 @@ export function onHomeworkFinish(data) { ...@@ -418,4 +418,4 @@ export function onHomeworkFinish(data) {
} else { } else {
console.log('onHomeworkFinish:' + JSON.stringify(data)); console.log('onHomeworkFinish:' + JSON.stringify(data));
} }
} }
\ No newline at end of file
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
"height": 336, "height": 336,
"platformSettings": {}, "platformSettings": {},
"subMetas": { "subMetas": {
"1orange": { "1orange_duiduipeng": {
"ver": "1.0.4", "ver": "1.0.4",
"uuid": "dabca43b-c1a7-4172-81f6-ef6127d1dd35", "uuid": "dabca43b-c1a7-4172-81f6-ef6127d1dd35",
"rawTextureUuid": "2a7fbc19-7b67-4ead-92a2-085ff53094e6", "rawTextureUuid": "2a7fbc19-7b67-4ead-92a2-085ff53094e6",
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
"height": 720, "height": 720,
"platformSettings": {}, "platformSettings": {},
"subMetas": { "subMetas": {
"bg": { "bg_duiduipeng": {
"ver": "1.0.4", "ver": "1.0.4",
"uuid": "ec2aeba2-b70b-41d2-b2b6-58f4bf81368d", "uuid": "ec2aeba2-b70b-41d2-b2b6-58f4bf81368d",
"rawTextureUuid": "ca696dc9-8fe6-466f-bb6b-56b09f6271b2", "rawTextureUuid": "ca696dc9-8fe6-466f-bb6b-56b09f6271b2",
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
"height": 67, "height": 67,
"platformSettings": {}, "platformSettings": {},
"subMetas": { "subMetas": {
"btn_left": { "btn_left_duiduipeng": {
"ver": "1.0.4", "ver": "1.0.4",
"uuid": "83419c05-6392-4a36-874e-762af37e2b72", "uuid": "83419c05-6392-4a36-874e-762af37e2b72",
"rawTextureUuid": "d84c192c-6fe9-4d56-98ca-4e2abf793372", "rawTextureUuid": "d84c192c-6fe9-4d56-98ca-4e2abf793372",
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
"height": 67, "height": 67,
"platformSettings": {}, "platformSettings": {},
"subMetas": { "subMetas": {
"btn_right": { "btn_right_duiduipeng": {
"ver": "1.0.4", "ver": "1.0.4",
"uuid": "e14c490d-6f87-43b4-a94c-3763988c64ed", "uuid": "e14c490d-6f87-43b4-a94c-3763988c64ed",
"rawTextureUuid": "2dbc95c5-7119-44ce-96d4-f90c9469fa32", "rawTextureUuid": "2dbc95c5-7119-44ce-96d4-f90c9469fa32",
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
"height": 144, "height": 144,
"platformSettings": {}, "platformSettings": {},
"subMetas": { "subMetas": {
"icon": { "icon_duiduipeng": {
"ver": "1.0.4", "ver": "1.0.4",
"uuid": "68e4d708-b7c4-4d97-9231-9c7d00e4298c", "uuid": "68e4d708-b7c4-4d97-9231-9c7d00e4298c",
"rawTextureUuid": "1122742b-2a4c-4f5b-8107-485a9c122efb", "rawTextureUuid": "1122742b-2a4c-4f5b-8107-485a9c122efb",
......
...@@ -84,7 +84,7 @@ ...@@ -84,7 +84,7 @@
<div style="display:flex ;"> <div style="display:flex ;">
<div> <div>
<app-audio-recorder [audioUrl]="item.questionTextAudio" <app-audio-recorder [audioUrl]="item.questionTextAudio"
(audioUploaded)="onAudioUploadSuccess($event, 'questionTextAudio')"></app-audio-recorder> (audioUploaded)="onAudioUploadSuccess($event, 'questionTextAudio',item,'audioName')"></app-audio-recorder>
</div> </div>
<div style="margin: 5px"> <div style="margin: 5px">
<span>{{ item.audioName}}</span> <span>{{ item.audioName}}</span>
...@@ -92,6 +92,31 @@ ...@@ -92,6 +92,31 @@
</div> </div>
</div> </div>
<div class="border-dashed" style="margin: 20px;width: 1000px;">
<div class="word-input-title">
<div>
<span>游戏背景音乐: </span>
</div>
<div>
<span style="color:rgb(201, 200, 200);margin-left:5px;font-size: 10px;"> *可不传,不传既无背景音乐</span>
</div>
</div>
<div style="display:flex ;margin-top: 10px;">
<div>
<app-audio-recorder [audioUrl]="item.bgAudio"
(audioUploaded)="onAudioUploadSuccess($event, 'bgAudio',item,'bgAudioName')">
</app-audio-recorder>
</div>
<div style="margin: 5px">
<span>{{ item.bgAudioName}}</span>
</div>
<div style="margin: 5px">
<span style="color: #169BD5;text-decoration: underline;" type="button" nzDanger
(click)="deleteBgAudio()">删除背景音</span>
</div>
</div>
</div>
<div style="margin: 20px;width: 1100px;"> <div style="margin: 20px;width: 1100px;">
<div *ngFor="let question of item.questions; let i = index"> <div *ngFor="let question of item.questions; let i = index">
...@@ -151,7 +176,7 @@ ...@@ -151,7 +176,7 @@
<div style="display: flex"> <div style="display: flex">
<div> <div>
<app-audio-recorder [audioUrl]="option.audio" <app-audio-recorder [audioUrl]="option.audio"
(audioUploaded)="onAudioUploadSuccess($event, 'audio', option)"> (audioUploaded)="onAudioUploadSuccess($event, 'audio', option,'audioName')">
</app-audio-recorder> </app-audio-recorder>
</div> </div>
<div style="margin: 5px"> <div style="margin: 5px">
...@@ -192,7 +217,7 @@ ...@@ -192,7 +217,7 @@
<div style="display: flex"> <div style="display: flex">
<div> <div>
<app-audio-recorder [audioUrl]="question.options[j+1].audio" <app-audio-recorder [audioUrl]="question.options[j+1].audio"
(audioUploaded)="onAudioUploadSuccess($event, 'audio', question.options[j+1])"> (audioUploaded)="onAudioUploadSuccess($event, 'audio', question.options[j+1],'audioName')">
</app-audio-recorder> </app-audio-recorder>
</div> </div>
<div style="margin: 5px"> <div style="margin: 5px">
...@@ -230,7 +255,7 @@ ...@@ -230,7 +255,7 @@
<div style="color: #f00;font-size: 12px;">为保证游戏效果,每题最多配置5对选项</div> <div style="color: #f00;font-size: 12px;">为保证游戏效果,每题最多配置5对选项</div>
</button> </button>
</div> </div>
<nz-modal [(nzVisible)]="isVisible" [nzTitle]="null" [nzContent]="modalContent" [nzFooter]="modalFooter" <nz-modal [(nzVisible)]="isVisible" [nzTitle]="null" [nzContent]="modalContent" [nzFooter]="modalFooter"
(nzOnCancel)="handleCancel()"> (nzOnCancel)="handleCancel()">
......
...@@ -91,6 +91,8 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -91,6 +91,8 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
questionText: "调皮的小猫将魔法卡牌打乱了顺序,快去整理魔法卡牌吧!你只需要将魔法卡牌配对成功,即可获得该对魔法卡牌。在规定的时间内,尽可能获得更多的魔法卡牌。游戏结束,根据获得的魔法卡牌的数量,你将获得相应的能量石奖励哟!开始挑战吧!", questionText: "调皮的小猫将魔法卡牌打乱了顺序,快去整理魔法卡牌吧!你只需要将魔法卡牌配对成功,即可获得该对魔法卡牌。在规定的时间内,尽可能获得更多的魔法卡牌。游戏结束,根据获得的魔法卡牌的数量,你将获得相应的能量石奖励哟!开始挑战吧!",
questionTextAudio: "http://staging-teach.cdn.ireadabc.com/cdff4df1edf580c26dcede1a9a1fd9db.mp3", questionTextAudio: "http://staging-teach.cdn.ireadabc.com/cdff4df1edf580c26dcede1a9a1fd9db.mp3",
questions: [], questions: [],
bgAudio: "",
bgAudioName: "",
audioName: "" audioName: ""
}; };
...@@ -144,20 +146,34 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -144,20 +146,34 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
it[key] = e.url; it[key] = e.url;
this.save(); this.save();
} }
deleteBgAudio() {
this.item.bgAudio = "";
this.item.bgAudioName = "";
this.save();
}
/** onAudioUploadSuccess(e, key, it = this.item,audioName) {
* 储存音频数据
* @param e
*/
onAudioUploadSuccess(e, key, it = this.item) {
let url = e.url; let url = e.url;
let sp = url.split(".mp3"); let sp = url.split(".mp3");
let u = sp[0] + "_l.mp3"; let u = sp[0] + "_l.mp3";
it[key] = u; it[key] = u;
it["audioName"] = e.name || ""; it[audioName] = e.name || "";
this.save(); this.save();
} }
/**
* 储存音频数据
* @param e
*/
// onAudioUploadSuccess(e, key, it = this.item) {
// let url = e.url;
// let sp = url.split(".mp3");
// let u = sp[0] + "_l.mp3";
// it[key] = u;
// it["audioName"] = e.name || "";
// this.save();
// }
/** /**
* 储存数据 * 储存数据
*/ */
......
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