😂🔫
This commit is contained in:
@ -36,9 +36,12 @@ import GmTools from '@/components/utilities/GmTools.vue'
|
||||
import { useSocketStore } from '@/stores/socket'
|
||||
import { useZoneEditorStore } from '@/stores/zoneEditor'
|
||||
import ZoneEditor from '@/components/utilities/zoneEditor/ZoneEditor.vue'
|
||||
import { useAssetStore } from '@/stores/assets'
|
||||
import type { Asset } from '@/types'
|
||||
|
||||
const socket = useSocketStore()
|
||||
const zoneEditorStore = useZoneEditorStore()
|
||||
const assetStore = useAssetStore()
|
||||
|
||||
onUnmounted(() => {
|
||||
socket.disconnectSocket()
|
||||
@ -64,23 +67,24 @@ const createGame = (game: Phaser.Game) => {
|
||||
}
|
||||
|
||||
const preloadScene = (scene: Phaser.Scene) => {
|
||||
type Asset = {
|
||||
key: string
|
||||
value: string
|
||||
type: 'base64' | 'link'
|
||||
}
|
||||
|
||||
|
||||
socket.connection.emit('assets:download', {}, (response: Asset[]) => {
|
||||
console.log(response);
|
||||
response.forEach((asset) => {
|
||||
if (asset.type === 'base64') {
|
||||
scene.textures.addBase64(asset.key, asset.value)
|
||||
}
|
||||
if (asset.type === 'link') {
|
||||
scene.load.image(asset.key, config.server_endpoint + '/assets' + asset.value)
|
||||
}
|
||||
assetStore.addAsset(asset)
|
||||
})
|
||||
})
|
||||
|
||||
assetStore.assets.forEach((asset) => {
|
||||
if (asset.type === 'link') {
|
||||
scene.load.image(asset.key, asset.value)
|
||||
}
|
||||
if (asset.type === 'base64') {
|
||||
scene.textures.addBase64(asset.key, asset.value)
|
||||
}
|
||||
})
|
||||
|
||||
scene.load.image('tiles', '/assets/zone/tiles.png')
|
||||
scene.load.image('walls', '/assets/zone/walls.png')
|
||||
scene.load.image('wall1', '/assets/zone/wall1.png')
|
||||
|
Reference in New Issue
Block a user