phaserjs / phaser

Phaser is a fun, free and fast 2D game framework for making HTML5 games for desktop and mobile web browsers, supporting Canvas and WebGL rendering.
https://phaser.io
MIT License
37.16k stars 7.1k forks source link

camera follow with deadzone and high zoom no longer smooth on v3.85.0 Beta 2 #6878

Closed Antriel closed 3 months ago

Antriel commented 3 months ago

Demo: https://phaser.io/sandbox/5rxAdUsy It's jittery in 85 beta 2, smooth before. Happens because of https://github.com/phaserjs/phaser/commit/26d85978d2494310c95760020ea62dca8b8b122a I think. Now the values jump a whole pixel, and then it smoothly follows to align. Before it smoothly followed constantly, as there was no rounding happening.

greptile-apps[bot] commented 3 months ago

For internal use only

To resolve the jittery camera follow issue in v3.85.0 Beta 2, modify the Camera.preRender method in src/cameras/2d/Camera.js. Specifically, remove or adjust the Math.floor application to the scroll factor when rounding is enabled. This change will revert the behavior to smooth following without pixel rounding. Example modification:

// src/cameras/2d/Camera.js
preRender: function () {
    // Remove or adjust this line
    // this.scrollX = Math.floor(this.scrollX);
    // this.scrollY = Math.floor(this.scrollY);
    // Add smooth following logic here if needed
}

References

/changelog/3.5 /changelog/3.5/CHANGELOG-v3.5.md /changelog/3.54 /changelog/3.23 /.github/ISSUE_TEMPLATE /changelog/3.54/CHANGELOG-v3.54.md /changelog/3.13/CHANGELOG-v3.13.md /changelog/3.80/CHANGELOG-v3.80.md /changelog/3.1.1 /changelog/3.13 /changelog/3.15 /changelog/3.85/CHANGELOG-v3.85.md /changelog/3.18/CHANGELOG-v3.18.md /changelog/3.9/CHANGELOG-v3.9.md /changelog/3.15/CHANGELOG-v3.15.md /.github/ISSUE_TEMPLATE/bug_report.md /.github/CONTRIBUTING.md /changelog/3.17/CHANGELOG-v3.17.md /changelog/3.1.1/CHANGELOG-v3.1.1.md /changelog/3.16.2/CHANGELOG-v3.16.2.md /src/cameras/2d/events/ZOOM_COMPLETE_EVENT.js /changelog/3.60/Camera.md /changelog/3.55.2/CHANGELOG-v3.55.2.md /changelog/3.11/CHANGELOG-v3.11.md /changelog/3.23/CHANGELOG-v3.23.md

#### About Greptile This response provides a starting point for your research, not a precise solution. Help us improve! Please leave a ๐Ÿ‘ if this is helpful and ๐Ÿ‘Ž if it is irrelevant. [Ask Greptile](https://app.greptile.com/chat/github/phaserjs/phaser/master) ยท [Edit Issue Bot Settings](https://app.greptile.com/apps/github)
photonstorm commented 3 months ago

Thank you for submitting this issue. We have fixed this and the fix has been pushed to the master branch. It will be part of the next release. If you get time to build and test it for yourself we would appreciate that.