|
@@ -1,8 +1,8 @@
|
|
|
<template>
|
|
|
<div class="game-container">
|
|
|
- <div id="gameCanvas" class="game-canvas"></div>
|
|
|
+ <div :id="'gameCanvas' + type" class="game-canvas"></div>
|
|
|
<canvas ref="canvasRef" :width="clientObj.width" :height="clientObj.height"
|
|
|
- style="position:fixed;left: 0; top: 0; z-index: 999;"></canvas>
|
|
|
+ style="position:absolute;left: 0; top: 0; z-index: 999;"></canvas>
|
|
|
<!-- 游戏启动界面 -->
|
|
|
<div v-if="currentScene === 'start'" class="gamestart">
|
|
|
<img v-if="currentScene === 'start'" src="/static/images/football/game_start.jpg" class="start_bg" />
|
|
@@ -67,7 +67,13 @@ const { proxy } = getCurrentInstance() as any;
|
|
|
const router = useRouter();
|
|
|
const emit = defineEmits(['confirmExit']);
|
|
|
const canvasRef = ref(null);
|
|
|
-
|
|
|
+//父值
|
|
|
+const props = defineProps({
|
|
|
+ type: {
|
|
|
+ type: String,
|
|
|
+ default: false
|
|
|
+ },
|
|
|
+});
|
|
|
|
|
|
const data = reactive<any>({
|
|
|
bodyposeData: {},//姿态信息
|
|
@@ -160,7 +166,7 @@ const initGame = () => {
|
|
|
type: Phaser.AUTO,
|
|
|
width: GAME_WIDTH,
|
|
|
height: GAME_HEIGHT,
|
|
|
- parent: 'gameCanvas',
|
|
|
+ parent: 'gameCanvas' + props.type,
|
|
|
physics: {
|
|
|
default: 'arcade',
|
|
|
arcade: {
|
|
@@ -1181,11 +1187,6 @@ const getTitle = (score) => {
|
|
|
return '足球传奇';
|
|
|
};
|
|
|
|
|
|
-// 组件挂载时初始化游戏
|
|
|
-onMounted(() => {
|
|
|
- initGame();
|
|
|
-});
|
|
|
-
|
|
|
// 监听场景变化
|
|
|
watch(currentScene, (newVal) => {
|
|
|
if (newVal === 'game' && game.value) {
|
|
@@ -1465,13 +1466,18 @@ function calculateAngleAtB(pointA, pointB, pointC) {
|
|
|
}
|
|
|
|
|
|
onBeforeMount(() => {
|
|
|
+});
|
|
|
+
|
|
|
+// 组件挂载时初始化游戏
|
|
|
+onMounted(() => {
|
|
|
clientObj.value = {
|
|
|
- width: document.documentElement.clientWidth,
|
|
|
- height: document.documentElement.clientHeight,
|
|
|
+ width: document.querySelector('.game-container').offsetWidth,
|
|
|
+ height: document.querySelector('.game-container').offsetHeight,
|
|
|
}
|
|
|
- getInit();
|
|
|
+ initGame();
|
|
|
});
|
|
|
|
|
|
+
|
|
|
// 组件卸载时清理事件监听
|
|
|
onUnmounted(() => {
|
|
|
if (game.value && game.value.events && scoreListener) {
|