From ba6012ad894c6c52d3a9a4f0f777c4b0788b00e4 Mon Sep 17 00:00:00 2001 From: Erik Onarheim Date: Mon, 18 Mar 2024 19:14:28 -0500 Subject: [PATCH] fix: TileMap culling did not work properly when using fixed updates lower than refresh rate --- CHANGELOG.md | 1 + src/engine/Screen.ts | 2 +- src/spec/ParallaxSpec.ts | 4 ++++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e8b7dcc5d..ee88db719 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). ### Fixed +- Fixed issue where `ex.TileMap` culling did not work properly when using fixed updates lower than refresh rate - Fixed incomplete types for font options in `ex.FontSource().toFont(options)` - Fixed issue with `ex.Loader` start button position when using CSS transforms - Fixed issue where adding scenes with the same name did not work when it was previously removed diff --git a/src/engine/Screen.ts b/src/engine/Screen.ts index 482981451..f31918ef2 100644 --- a/src/engine/Screen.ts +++ b/src/engine/Screen.ts @@ -758,7 +758,7 @@ export class Screen { Vector.Half) .scale(vec(1/this._camera.zoom, 1/this._camera.zoom)) .rotate(this._camera.rotation) - .translate(this._camera.pos); + .translate(this._camera.drawPos); return bounds; } diff --git a/src/spec/ParallaxSpec.ts b/src/spec/ParallaxSpec.ts index 23340ae0e..f1f45c24a 100644 --- a/src/spec/ParallaxSpec.ts +++ b/src/spec/ParallaxSpec.ts @@ -25,6 +25,7 @@ describe('A Parallax Component', () => { const game = TestUtils.engine({width: 500, height: 500}, ['use-canvas-context']); await TestUtils.runToReady(game); game.currentScene.camera.pos = ex.vec(0, 0); + game.currentScene.camera.drawPos = ex.vec(0, 0); const clock = game.clock as ex.TestClock; @@ -33,6 +34,7 @@ describe('A Parallax Component', () => { game.add(actor); game.currentScene.camera.pos = ex.vec(100, 100); + game.currentScene.camera.drawPos = ex.vec(100, 100); expect(game.currentScene.camera.pos).toBeVector(ex.vec(100, 100)); clock.step(16); @@ -40,12 +42,14 @@ describe('A Parallax Component', () => { expect(actor.hasTag('ex.offscreen')).toBeFalse(); game.currentScene.camera.pos = ex.vec(520, 520); + game.currentScene.camera.drawPos = ex.vec(520, 520); clock.step(); expect(game.currentScene.camera.pos).toBeVector(ex.vec(520, 520)); await expectAsync(game.canvas).toEqualImage('src/spec/images/ParallaxSpec/parallax2.png'); expect(actor.hasTag('ex.offscreen')).toBeFalse(); game.currentScene.camera.pos = ex.vec(620, 620); + game.currentScene.camera.drawPos = ex.vec(620, 620); clock.step(); expect(game.currentScene.camera.pos).toBeVector(ex.vec(620, 620)); expect(actor.hasTag('ex.offscreen')).toBeTrue();