diff --git a/CHANGELOG.md b/CHANGELOG.md index 3237e2822..4de5583c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -205,7 +205,8 @@ This project adheres to [Semantic Versioning](http://semver.org/). ### Fixed -- Fixes an issue where a collider that was part of a contact that was deleted did not fire a collision end event, this was unexpected +- Fixed errant warning about resolution when using `pixelRatio` on low res games to upscale +- Fixes an issue where a collider that was part of a contact that was deleted did not fire a collision end event, this was unexpected - Fixes an issue where you may want to have composite colliders behave as constituent colliders for the purposes of start/end collision events. A new property is added to physics config, the current behavior is the default which is `'together'`, this means the whole composite collider is treated as 1 collider for onCollisionStart/onCollisionEnd. Now you can configure a `separate` which will fire onCollisionStart/onCollisionEnd for every separate collider included in the composite (useful if you are building levels or things with gaps that you need to disambiguate). You can also configure this on a per composite level to mix and match `CompositeCollider.compositeStrategy` - Fixed issue where particles would have an errant draw if using a particle sprite - Fixed issue where a null/undefined graphics group member graphic would cause a crash, now logs a warning. diff --git a/src/engine/Director/Loader.ts b/src/engine/Director/Loader.ts index e6b6e4d55..5d1b183fc 100644 --- a/src/engine/Director/Loader.ts +++ b/src/engine/Director/Loader.ts @@ -268,11 +268,14 @@ export class Loader extends DefaultLoader { await this.showPlayButton(); } + private _configuredPixelRatio: number | null = null; public override async onBeforeLoad(): Promise { + this._configuredPixelRatio = this.screen.pixelRatioOverride; // Push the current user entered resolution/viewport this.screen.pushResolutionAndViewport(); // Configure resolution for loader, it expects resolution === viewport this.screen.resolution = this.screen.viewport; + this.screen.pixelRatioOverride = 1; this.screen.applyResolutionAndViewport(); this.canvas.width = this.engine.canvas.width; @@ -283,6 +286,7 @@ export class Loader extends DefaultLoader { // eslint-disable-next-line require-await public override async onAfterLoad(): Promise { + this.screen.pixelRatioOverride = this._configuredPixelRatio; this.screen.popResolutionAndViewport(); this.screen.applyResolutionAndViewport(); this.dispose(); diff --git a/src/engine/Screen.ts b/src/engine/Screen.ts index 27eb1bb2b..97e84b72c 100644 --- a/src/engine/Screen.ts +++ b/src/engine/Screen.ts @@ -381,6 +381,9 @@ export class Screen { // Asking the window.devicePixelRatio is expensive we do it once private _devicePixelRatio = this._calculateDevicePixelRatio(); + /** + * Returns the computed pixel ratio, first using any override, then the device pixel ratio + */ public get pixelRatio(): number { if (this._pixelRatioOverride) { return this._pixelRatioOverride; @@ -389,6 +392,19 @@ export class Screen { return this._devicePixelRatio; } + /** + * Get or set the pixel ratio override + * + * You will need to call applyResolutionAndViewport() affect change on the screen + */ + public get pixelRatioOverride(): number | undefined { + return this._pixelRatioOverride; + } + + public set pixelRatioOverride(value: number | undefined) { + this._pixelRatioOverride = value; + } + public get isHiDpi() { return this.pixelRatio !== 1; }