Browse Source

添加音频管理

sa03 6 years ago
parent
commit
24084194f9

+ 0 - 0
assets/audio/.gitkeep


BIN
assets/audio/bgm.mp3


+ 6 - 0
assets/audio/bgm.mp3.meta

@@ -0,0 +1,6 @@
+{
+  "ver": "2.0.0",
+  "uuid": "7374d2c6-3344-4daf-9984-b97d4de91e8f",
+  "downloadMode": 0,
+  "subMetas": {}
+}

BIN
assets/audio/button.mp3


+ 6 - 0
assets/audio/button.mp3.meta

@@ -0,0 +1,6 @@
+{
+  "ver": "2.0.0",
+  "uuid": "322e32cc-4c7c-4eaf-972d-f5341acad92f",
+  "downloadMode": 0,
+  "subMetas": {}
+}

BIN
assets/audio/getCoin.mp3


+ 6 - 0
assets/audio/getCoin.mp3.meta

@@ -0,0 +1,6 @@
+{
+  "ver": "2.0.0",
+  "uuid": "80a542cd-d8cc-4a13-bfa1-232468cfde7e",
+  "downloadMode": 0,
+  "subMetas": {}
+}

BIN
assets/audio/gift.mp3


+ 6 - 0
assets/audio/gift.mp3.meta

@@ -0,0 +1,6 @@
+{
+  "ver": "2.0.0",
+  "uuid": "d2b672f2-e32e-4e9d-a9aa-703fc8ae67f1",
+  "downloadMode": 0,
+  "subMetas": {}
+}

BIN
assets/audio/signFail.mp3


+ 6 - 0
assets/audio/signFail.mp3.meta

@@ -0,0 +1,6 @@
+{
+  "ver": "2.0.0",
+  "uuid": "bf21f0e6-f774-492b-9fa1-5b0ccaa2959f",
+  "downloadMode": 0,
+  "subMetas": {}
+}

BIN
assets/audio/signSuccess.mp3


+ 6 - 0
assets/audio/signSuccess.mp3.meta

@@ -0,0 +1,6 @@
+{
+  "ver": "2.0.0",
+  "uuid": "99a801f4-f8fd-4093-b8d4-fdfd0d4350e1",
+  "downloadMode": 0,
+  "subMetas": {}
+}

BIN
assets/audio/updateBuilding.mp3


+ 6 - 0
assets/audio/updateBuilding.mp3.meta

@@ -0,0 +1,6 @@
+{
+  "ver": "2.0.0",
+  "uuid": "15cef12a-98b3-42a1-83ee-fd0a62495893",
+  "downloadMode": 0,
+  "subMetas": {}
+}

+ 34 - 0
assets/scene/game.fire

@@ -109,6 +109,9 @@
       },
       {
         "__id__": 227
+      },
+      {
+        "__id__": 228
       }
     ],
     "_prefab": null,
@@ -8080,5 +8083,36 @@
     "game": {
       "__id__": 3
     }
+  },
+  {
+    "__type__": "a6688FwcO5Bp55ipFMPLteD",
+    "_name": "",
+    "_objFlags": 0,
+    "node": {
+      "__id__": 2
+    },
+    "_enabled": true,
+    "bgm": {
+      "__uuid__": "7374d2c6-3344-4daf-9984-b97d4de91e8f"
+    },
+    "buttonAudio": {
+      "__uuid__": "322e32cc-4c7c-4eaf-972d-f5341acad92f"
+    },
+    "giftAudio": {
+      "__uuid__": "d2b672f2-e32e-4e9d-a9aa-703fc8ae67f1"
+    },
+    "updateBuildingAudio": {
+      "__uuid__": "15cef12a-98b3-42a1-83ee-fd0a62495893"
+    },
+    "signSuccessAudio": {
+      "__uuid__": "99a801f4-f8fd-4093-b8d4-fdfd0d4350e1"
+    },
+    "signFailAudio": {
+      "__uuid__": "bf21f0e6-f774-492b-9fa1-5b0ccaa2959f"
+    },
+    "getCoinAudio": {
+      "__uuid__": "80a542cd-d8cc-4a13-bfa1-232468cfde7e"
+    },
+    "volume": 1
   }
 ]

+ 80 - 0
assets/scripts/AudioMng.js

@@ -0,0 +1,80 @@
+cc.Class({
+    extends: cc.Component,
+
+    properties: {
+        bgm: {
+            tooltip: '背景音乐',
+            default: null,
+            type: cc.AudioClip
+        },
+        buttonAudio: {
+            tooltip: '按钮音效',
+            default: null,
+            type: cc.AudioClip
+        },
+        giftAudio: {
+            tooltip: '获得奖励音效',
+            default: null,
+            type: cc.AudioClip
+        },
+        updateBuildingAudio: {
+            tooltip: '升级建筑音效',
+            default: null,
+            type: cc.AudioClip
+        },
+        signSuccessAudio: {
+            tooltip: '抢夺、进阶成功音效',
+            default: null,
+            type: cc.AudioClip
+        },
+        signFailAudio: {
+            tooltip: '抢夺、进阶失败音效',
+            default: null,
+            type: cc.AudioClip
+        },
+        getCoinAudio: {
+            tooltip: '收取金币音效',
+            default: null,
+            type: cc.AudioClip
+        },
+        volume: {
+            tooltip: '总音量',
+            default: 1,
+            type: cc.Integer
+        }
+    },
+
+    onLoad () {
+        this.currentAudio = {};
+    },
+
+    /**
+     * 暂停所有音效
+     */
+    stopAll () {
+        cc.audioEngine.stopAll();
+    },
+
+    /**
+     * 播放背景音乐
+     */
+    playBgm () {
+        this.currentAudio['bgm'] = cc.audioEngine.play(this.bgm, true, this.volume);
+    },
+
+    /**
+     * 暂停播放背景音乐
+     */
+    stopBgm () {
+        cc.audioEngine.stop(this.currentAudio['bgm']);
+    },
+
+    /**
+     * 播放按钮音效
+     */
+    playButton () {
+        cc.audioEngine.play(this.buttonAudio, false, this.volume);
+    }
+
+    // update (dt) {},
+});

+ 9 - 0
assets/scripts/AudioMng.js.meta

@@ -0,0 +1,9 @@
+{
+  "ver": "1.0.5",
+  "uuid": "a6688170-70ee-41a7-9e62-a4530f2ed783",
+  "isPlugin": false,
+  "loadPluginInWeb": true,
+  "loadPluginInNative": true,
+  "loadPluginInEditor": false,
+  "subMetas": {}
+}