Set a global dirty flag on resize
This adds a global "Dirty" flag at the Game level and sets it each time the ScaleManager is modified. This fixes a bug where the game was not redrawn when a CoWebsite was opening/closing.
This commit is contained in:
parent
867f783d5e
commit
24dfa2703d
3 changed files with 43 additions and 10 deletions
|
@ -1,18 +1,21 @@
|
|||
import {HdpiManager} from "./HdpiManager";
|
||||
import ScaleManager = Phaser.Scale.ScaleManager;
|
||||
import {coWebsiteManager} from "../../WebRtc/CoWebsiteManager";
|
||||
import type {Game} from "../Game/Game";
|
||||
|
||||
|
||||
class WaScaleManager {
|
||||
private hdpiManager: HdpiManager;
|
||||
private scaleManager!: ScaleManager;
|
||||
private game!: Game;
|
||||
|
||||
public constructor(private minGamePixelsNumber: number, private absoluteMinPixelNumber: number) {
|
||||
this.hdpiManager = new HdpiManager(minGamePixelsNumber, absoluteMinPixelNumber);
|
||||
}
|
||||
|
||||
public setScaleManager(scaleManager: ScaleManager) {
|
||||
this.scaleManager = scaleManager;
|
||||
public setGame(game: Game): void {
|
||||
this.scaleManager = game.scale;
|
||||
this.game = game;
|
||||
}
|
||||
|
||||
public applyNewSize() {
|
||||
|
@ -32,6 +35,8 @@ class WaScaleManager {
|
|||
const style = this.scaleManager.canvas.style;
|
||||
style.width = Math.ceil(realSize.width / devicePixelRatio) + 'px';
|
||||
style.height = Math.ceil(realSize.height / devicePixelRatio) + 'px';
|
||||
|
||||
this.game.markDirty();
|
||||
}
|
||||
|
||||
public get zoomModifier(): number {
|
||||
|
@ -42,6 +47,7 @@ class WaScaleManager {
|
|||
this.hdpiManager.zoomModifier = zoomModifier;
|
||||
this.applyNewSize();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export const waScaleManager = new WaScaleManager(640*480, 196*196);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue