Skip to content

Commit

Permalink
Add pixel snap for Parallax2D
Browse files Browse the repository at this point in the history
  • Loading branch information
markdibarry committed Jul 7, 2024
1 parent b97110c commit 8888e92
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion scene/2d/parallax_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
}
}
}

Expand Down

0 comments on commit 8888e92

Please sign in to comment.