浏览代码

声音BUG 修复

greg 4 年之前
父节点
当前提交
6fa80c7faf
共有 2 个文件被更改,包括 13 次插入9 次删除
  1. 7 6
      assets/resources/scenes/PreloadingScene.scene
  2. 6 3
      assets/scripts/engines/sounds/SoundManager.ts

+ 7 - 6
assets/resources/scenes/PreloadingScene.scene

@@ -1513,6 +1513,7 @@
         "__id__": 49
       }
     ],
+    "_prefab": null,
     "_lpos": {
       "__type__": "cc.Vec3",
       "x": 0,
@@ -1660,7 +1661,7 @@
     "_lpos": {
       "__type__": "cc.Vec3",
       "x": 0,
-      "y": -412.273,
+      "y": -538.951,
       "z": 0
     },
     "_lrot": {
@@ -1809,7 +1810,7 @@
     "_lpos": {
       "__type__": "cc.Vec3",
       "x": 0,
-      "y": 55.06200000000001,
+      "y": 34.38,
       "z": 0
     },
     "_lrot": {
@@ -1845,7 +1846,7 @@
     "_priority": 0,
     "_contentSize": {
       "__type__": "cc.Size",
-      "width": 277.23,
+      "width": 207.92,
       "height": 50.4
     },
     "_anchorPoint": {
@@ -1877,8 +1878,8 @@
     "_string": "PreloadingView",
     "_horizontalAlign": 1,
     "_verticalAlign": 1,
-    "_actualFontSize": 40,
-    "_fontSize": 40,
+    "_actualFontSize": 30,
+    "_fontSize": 30,
     "_fontFamily": "Arial",
     "_lineHeight": 40,
     "_overflow": 0,
@@ -1980,7 +1981,7 @@
     "_top": 0,
     "_bottom": 0,
     "_horizontalCenter": 0,
-    "_verticalCenter": -412.273,
+    "_verticalCenter": -538.951,
     "_isAbsLeft": true,
     "_isAbsRight": true,
     "_isAbsTop": true,

+ 6 - 3
assets/scripts/engines/sounds/SoundManager.ts

@@ -161,7 +161,7 @@ class AudioChannel{
     }
 
     Play(soundUrl:string,isLoop:boolean):void{
-        if(this.soundUrl==soundUrl){
+        if(this.soundUrl==soundUrl&&this.state==1){
             return;
         }
         this.soundUrl=soundUrl;
@@ -194,9 +194,12 @@ class AudioChannel{
         if(this.aSComponent==null){
             return;
         }
-        this.aSComponent.stop();
-        this.aSComponent.clip=audioClip;
+        if(this.aSComponent.clip!=audioClip){
+            this.aSComponent.stop();
+            this.aSComponent.clip=audioClip;
+        }
         this.aSComponent.loop=this.isLoop;
+        this.aSComponent.currentTime=0;
         this.aSComponent.play();
     }