-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2a6738f
commit 8a70798
Showing
3 changed files
with
42 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,35 @@ | ||
<script setup lang="ts"> | ||
import { onMounted, onUnmounted, ref } from 'vue'; | ||
import { EventBus } from './EventBus'; | ||
import StartGame from './main'; | ||
import Phaser from 'phaser'; | ||
import { onMounted, onUnmounted, ref } from "vue"; | ||
import { EventBus } from "./EventBus"; | ||
import StartGame from "./main"; | ||
import Phaser from "phaser"; | ||
// Save the current scene instance | ||
const scene = ref(); | ||
const game = ref(); | ||
const emit = defineEmits(['current-active-scene']); | ||
const emit = defineEmits(["current-active-scene"]); | ||
onMounted(() => { | ||
game.value = StartGame("game-container"); | ||
EventBus.on("current-scene-ready", (scene_instance: Phaser.Scene) => { | ||
emit("current-active-scene", scene_instance); | ||
game.value = StartGame('game-container'); | ||
EventBus.on('current-scene-ready', (scene_instance: Phaser.Scene) => { | ||
emit('current-active-scene', scene_instance); | ||
scene.value = scene_instance; | ||
}); | ||
}); | ||
onUnmounted(() => { | ||
if (game.value) | ||
{ | ||
if (game.value) { | ||
game.value.destroy(true); | ||
game.value = null; | ||
} | ||
}); | ||
defineExpose({ scene, game }); | ||
</script> | ||
|
||
<template> | ||
<div id="game-container"></div> | ||
</template> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters