Merge pull request #94014 from markdibarry/parallax-snap
Add pixel snap for `Parallax2D`
This commit is contained in:
commit
ff8050efda
1 changed files with 6 additions and 1 deletions
|
@ -31,6 +31,7 @@
|
||||||
#include "parallax_2d.h"
|
#include "parallax_2d.h"
|
||||||
|
|
||||||
#include "core/config/project_settings.h"
|
#include "core/config/project_settings.h"
|
||||||
|
#include "scene/main/viewport.h"
|
||||||
|
|
||||||
void Parallax2D::_notification(int p_what) {
|
void Parallax2D::_notification(int p_what) {
|
||||||
switch (p_what) {
|
switch (p_what) {
|
||||||
|
@ -72,8 +73,12 @@ 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) {
|
void Parallax2D::_camera_moved(const Transform2D &p_transform, const Point2 &p_screen_offset, const Point2 &p_adj_screen_pos) {
|
||||||
if (!ignore_camera_scroll) {
|
if (!ignore_camera_scroll) {
|
||||||
|
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);
|
set_screen_offset(p_adj_screen_pos);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Parallax2D::_update_process() {
|
void Parallax2D::_update_process() {
|
||||||
|
|
Loading…
Reference in a new issue