From 8888e9216fbbb804d75061266c59e036acc2895a Mon Sep 17 00:00:00 2001 From: Mark DiBarry Date: Sat, 6 Jul 2024 18:34:25 -0400 Subject: [PATCH] Add pixel snap for Parallax2D --- scene/2d/parallax_2d.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scene/2d/parallax_2d.cpp b/scene/2d/parallax_2d.cpp index aacab3213d9..fb04eec7370 100644 --- a/scene/2d/parallax_2d.cpp +++ b/scene/2d/parallax_2d.cpp @@ -31,6 +31,7 @@ #include "parallax_2d.h" #include "core/config/project_settings.h" +#include "scene/main/viewport.h" void Parallax2D::_notification(int p_what) { switch (p_what) { @@ -72,7 +73,11 @@ void Parallax2D::_validate_property(PropertyInfo &p_property) const { void Parallax2D::_camera_moved(const Transform2D &p_transform, const Point2 &p_screen_offset, const Point2 &p_adj_screen_pos) { if (!ignore_camera_scroll) { - set_screen_offset(p_adj_screen_pos); + if (get_viewport() && get_viewport()->is_snap_2d_transforms_to_pixel_enabled()) { + set_screen_offset((p_adj_screen_pos + Vector2(0.5, 0.5)).floor()); + } else { + set_screen_offset(p_adj_screen_pos); + } } }