fix texture reuse on run cycle restart + expose debug kill
- Remove existing tilemap/minimap textures before recreating (prevents "Texture key already in use" error on second run) - Expose __game and __debugKill for dev console testing Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
import Phaser from 'phaser';
|
||||
import { gameConfig } from './config';
|
||||
|
||||
new Phaser.Game(gameConfig);
|
||||
const game = new Phaser.Game(gameConfig);
|
||||
|
||||
// Expose for debug console access
|
||||
(window as unknown as Record<string, unknown>).__game = game;
|
||||
|
||||
@@ -251,6 +251,11 @@ export class GameScene extends Phaser.Scene {
|
||||
this.time.delayedCall(500, () => {
|
||||
advancePhase(this.runState); // Awakening → Exploration
|
||||
});
|
||||
|
||||
// Debug: expose kill method for testing death cycle
|
||||
(this as unknown as Record<string, unknown>).__debugKill = () => {
|
||||
Health.current[this.playerEid] = 0;
|
||||
};
|
||||
}
|
||||
|
||||
/** Give the player their school's starting elements */
|
||||
|
||||
@@ -82,6 +82,10 @@ export class Minimap {
|
||||
const canvasW = w * scale;
|
||||
const canvasH = h * scale;
|
||||
|
||||
// Remove old texture if re-entering scene (run cycle)
|
||||
if (scene.textures.exists('minimap')) {
|
||||
scene.textures.remove('minimap');
|
||||
}
|
||||
const canvasTexture = scene.textures.createCanvas('minimap', canvasW, canvasH);
|
||||
const ctx = canvasTexture.getContext();
|
||||
|
||||
|
||||
@@ -15,7 +15,12 @@ export function createWorldTilemap(
|
||||
const { grid, biome } = worldData;
|
||||
const textureKey = `tileset-${biome.id}`;
|
||||
|
||||
// 1. Generate tileset texture
|
||||
// 1. Remove old texture if re-entering scene (run cycle)
|
||||
if (scene.textures.exists(textureKey)) {
|
||||
scene.textures.remove(textureKey);
|
||||
}
|
||||
|
||||
// 2. Generate tileset texture
|
||||
createTilesetTexture(scene, biome.tiles, biome.tileSize, textureKey);
|
||||
|
||||
// 2. Create tilemap from grid
|
||||
|
||||
Reference in New Issue
Block a user