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 Phaser from 'phaser';
|
||||||
import { gameConfig } from './config';
|
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;
|
||||||
|
|||||||
@@ -247,10 +247,15 @@ export class GameScene extends Phaser.Scene {
|
|||||||
// 11. Launch UIScene overlay
|
// 11. Launch UIScene overlay
|
||||||
this.scene.launch('UIScene');
|
this.scene.launch('UIScene');
|
||||||
|
|
||||||
// Transition from Awakening to Exploration after a moment
|
// Transition from Awakening to Exploration after a moment
|
||||||
this.time.delayedCall(500, () => {
|
this.time.delayedCall(500, () => {
|
||||||
advancePhase(this.runState); // Awakening → Exploration
|
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 */
|
/** Give the player their school's starting elements */
|
||||||
|
|||||||
@@ -82,6 +82,10 @@ export class Minimap {
|
|||||||
const canvasW = w * scale;
|
const canvasW = w * scale;
|
||||||
const canvasH = h * 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 canvasTexture = scene.textures.createCanvas('minimap', canvasW, canvasH);
|
||||||
const ctx = canvasTexture.getContext();
|
const ctx = canvasTexture.getContext();
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,12 @@ export function createWorldTilemap(
|
|||||||
const { grid, biome } = worldData;
|
const { grid, biome } = worldData;
|
||||||
const textureKey = `tileset-${biome.id}`;
|
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);
|
createTilesetTexture(scene, biome.tiles, biome.tileSize, textureKey);
|
||||||
|
|
||||||
// 2. Create tilemap from grid
|
// 2. Create tilemap from grid
|
||||||
|
|||||||
Reference in New Issue
Block a user