瀏覽代碼

游戏调整

wangxy 4 月之前
父節點
當前提交
2edae733f3
共有 2 個文件被更改,包括 17 次插入15 次删除
  1. 3 14
      pages/game/components/foodSelect.vue
  2. 14 1
      pages/game/components/useAudio.js

+ 3 - 14
pages/game/components/foodSelect.vue

@@ -43,15 +43,11 @@
 	})
 	
 	const popupRef = ref(null);
-	const isCanShow = ref(true);
-	
-	
+
 	function handleOpen() {
-		if (!isCanShow.value) {
-			return;
-		}
 		popupRef.value.open();
-	}
+    uni.$emit('food-select-open')
+  }
 	function handleClose() {
 		popupRef.value.close();
 	}
@@ -59,13 +55,6 @@
 		emits('weishi',shiwu);
 	}
 	
-	uni.$on('play-audio', () => {
-		isCanShow.value = false;
-	})
-	uni.$on('play-audio-ended', () => {
-		isCanShow.value = true;
-	})
-	
 	defineExpose({
 		handleClose
 	})

+ 14 - 1
pages/game/components/useAudio.js

@@ -72,6 +72,13 @@ export function useAudio (grouthType) {
 	onHide(() => {
 		innerAudioContext.stop();
 	})
+
+	// 展开食物停止播放
+	uni.$on('food-select-open', () => {
+		innerAudioContext.stop();
+		audioIndex.value = 0;
+	})
+
 	
 	watch(grouthType, () => {
 		if (defaultGrouthType.value != grouthType.value) {
@@ -106,13 +113,19 @@ export function useHuDong(props) {
 		myAudio.play();
 	}
 	
-	
+	// 播放开始切换动画
 	uni.$on('play-audio', () => {
 		imgUrl.value = imageList[props.growthType][1]
 	})
+	// 播放结束恢复默认
 	uni.$on('play-audio-ended', () => {
 		imgUrl.value = imageList[props.growthType][0]
 	})
+	// 展开食物恢复默认
+	uni.$on('food-select-open', () => {
+		imgUrl.value = imageList[props.growthType][0]
+	})
+	
 	return {
 		init,
 		doTouch,