Receive frameCount for assets from server

This commit is contained in:
Dennis Postma 2024-09-28 00:59:10 +02:00
parent 2223491571
commit 104e9e46fb
3 changed files with 19 additions and 17 deletions

View File

@ -1,26 +1,26 @@
<template>
<div class="flex justify-center items-center h-dvh relative">
<GmTools v-if="isLoaded && gameStore.character?.role === 'gm'" />
<GmPanel v-if="isLoaded && gameStore.character?.role === 'gm'" />
<GmTools v-if="gameStore.character?.role === 'gm'" />
<GmPanel v-if="gameStore.character?.role === 'gm'" />
<div v-if="!zoneEditorStore.active">
<Game :config="gameConfig" @create="createGame" class="111mt-[-60px]">
<Scene name="main" @preload="preloadScene" @create="createScene">
<div v-if="isLoaded">
<Inventory />
</div>
<div v-if="isLoaded" class="fixed inset-x-0 top-0 flex justify-start items-end p-10 pointer-events-none">
<div class="pointer-events-auto">
<Hud />
<div class="fixed inset-x-0 top-0 flex justify-start items-end p-10 pointer-events-none">
<div class="pointer-events-auto">
<Hud />
</div>
</div>
</div>
<Zone />
<div class="fixed inset-x-0 bottom-0 flex justify-between gap-5 items-end py-10 px-5 xxs:p-10 pointer-events-none max-md:flex-wrap max-md:flex-col-reverse">
<div class="pointer-events-auto w-full">
<Chat />
</div>
<div class="pointer-events-auto max-xs:m-auto mr-auto">
<Menubar />
<Zone />
<div class="fixed inset-x-0 bottom-0 flex justify-between gap-5 items-end py-10 px-5 xxs:p-10 pointer-events-none max-md:flex-wrap max-md:flex-col-reverse">
<div class="pointer-events-auto w-full">
<Chat />
</div>
<div class="pointer-events-auto max-xs:m-auto mr-auto">
<Menubar />
</div>
</div>
</div>
</Scene>
@ -138,11 +138,12 @@ const createScene = async (scene: Phaser.Scene) => {
gameStore.assets.forEach((asset) => {
if (asset.group !== 'sprite_animations') return
console.log(asset.frameCount)
scene.anims.create({
key: asset.key,
frameRate: 7,
/** @TODO: Fix end, which is total amount of frames */
frames: scene.anims.generateFrameNumbers(asset.key, { start: 0, end: 4 }),
frames: scene.anims.generateFrameNumbers(asset.key, { start: 0, end: asset.frameCount! - 1 }),
repeat: -1
})
})

View File

@ -7,6 +7,7 @@ export type Asset = {
key: string
url: string
group: 'tiles' | 'objects' | 'sprites' | 'sprite_animations' | 'sound' | 'music' | 'ui' | 'font' | 'other'
frameCount?: number
frameWidth?: number
frameHeight?: number
}