Prevent loading anims more than once

This commit is contained in:
2024-11-13 15:42:21 +01:00
parent 1888521762
commit d9947e29cf
2 changed files with 81 additions and 78 deletions

View File

@ -72,6 +72,9 @@ export async function loadSpriteTextures(scene: Phaser.Scene, sprite: Sprite) {
// If the sprite is not animated, skip
if (!sprite_action.isAnimated) continue
// Check if animation already exists
if (scene.anims.get(sprite_action.key)) continue
// Add the animation to the scene
const anim = scene.textures.get(sprite_action.key)
scene.textures.addSpriteSheet(sprite_action.key, anim, { frameWidth: sprite_action.frameWidth ?? 0, frameHeight: sprite_action.frameHeight ?? 0 })