Fix black screen: Optimize massive ground using Infinite Scroll technique
This commit is contained in:
@@ -104,10 +104,18 @@ export default class GrassSceneClean extends Phaser.Scene {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// --- 1. PODLAGA (The Foundation) ---
|
// --- 1. PODLAGA (The Foundation) ---
|
||||||
// Level 0, Locked to Z = -100
|
// OPTIMIZATION: Instead of one massive 32000x32000 tileSprite which crashes WebGL,
|
||||||
this.ground = this.add.tileSprite(WORLD_W / 2, WORLD_H / 2, WORLD_W, WORLD_H, 'ground_base');
|
// we use a smaller one that follows the camera (Infinite Scroll technique).
|
||||||
this.ground.setTileScale(1, 1);
|
|
||||||
|
// Size it to cover the screen even when zoomed out (0.5x zoom -> need 2x size)
|
||||||
|
const BG_W = this.scale.width * 2.5;
|
||||||
|
const BG_H = this.scale.height * 2.5;
|
||||||
|
|
||||||
|
this.ground = this.add.tileSprite(this.scale.width / 2, this.scale.height / 2, BG_W, BG_H, 'ground_base');
|
||||||
|
this.ground.setScrollFactor(0); // Sticks to camera
|
||||||
this.ground.setDepth(-100);
|
this.ground.setDepth(-100);
|
||||||
|
|
||||||
|
// Note: We need to update tilePosition in update() loop to match camera scroll!
|
||||||
|
|
||||||
// --- 2. STREAM SYSTEM (Head + Extensions) ---
|
// --- 2. STREAM SYSTEM (Head + Extensions) ---
|
||||||
// REMOVED PER USER REQUEST (Clean Start)
|
// REMOVED PER USER REQUEST (Clean Start)
|
||||||
@@ -717,6 +725,15 @@ export default class GrassSceneClean extends Phaser.Scene {
|
|||||||
}
|
}
|
||||||
|
|
||||||
update() {
|
update() {
|
||||||
|
// --- GROUND INFINITE SCROLL ---
|
||||||
|
if (this.ground) {
|
||||||
|
this.ground.tilePositionX = this.cameras.main.scrollX;
|
||||||
|
this.ground.tilePositionY = this.cameras.main.scrollY;
|
||||||
|
// Also need to move the sprite itself to stay centered on camera
|
||||||
|
this.ground.x = this.cameras.main.scrollX + this.scale.width / 2;
|
||||||
|
this.ground.y = this.cameras.main.scrollY + this.scale.height / 2;
|
||||||
|
}
|
||||||
|
|
||||||
// --- FOG MOVEMENT ---
|
// --- FOG MOVEMENT ---
|
||||||
/*
|
/*
|
||||||
if (this.fog1) {
|
if (this.fog1) {
|
||||||
|
|||||||
Reference in New Issue
Block a user