* Unload a character sprite or all sprites for a character * Uses the registered 'image' loader
(characterId: string, spriteName?: string)
| 83 | * Uses the registered 'image' loader |
| 84 | */ |
| 85 | private unloadCharacter(characterId: string, spriteName?: string): void { |
| 86 | const loaderConfig = Preload.getLoader('image'); |
| 87 | if (!loaderConfig) { |
| 88 | console.warn(`Unload: Image loader not registered`); |
| 89 | return; |
| 90 | } |
| 91 | |
| 92 | if (spriteName) { |
| 93 | // Unload single sprite |
| 94 | if (!loaderConfig.cache.delete) { |
| 95 | console.warn(`Unload: Image loader does not support delete operation`); |
| 96 | return; |
| 97 | } |
| 98 | const cacheKey = `characters/${characterId}/${spriteName}`; |
| 99 | loaderConfig.cache.delete(this.engine, cacheKey); |
| 100 | } else { |
| 101 | // Unload all sprites for this character |
| 102 | if (!loaderConfig.cache.clear) { |
| 103 | console.warn(`Unload: Image loader does not support clear operation`); |
| 104 | return; |
| 105 | } |
| 106 | loaderConfig.cache.clear(this.engine, `characters/${characterId}/`); |
| 107 | } |
| 108 | } |
| 109 | |
| 110 | /** |
| 111 | * Unload all assets in a block |
no test coverage detected