diff options
author | Juan Linietsky <reduzio@gmail.com> | 2015-10-13 15:53:34 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2015-10-13 15:53:34 -0300 |
commit | 79e5ced7e668fa53567ac6aaf5a26393cea6c9a2 (patch) | |
tree | f2c575f1957ab443eef49598f6f46c4285b4450c /scene/2d/sprite.cpp | |
parent | b3cda43a0fb49e1cb9c8414077a23fa4b61ede38 (diff) | |
download | redot-engine-79e5ced7e668fa53567ac6aaf5a26393cea6c9a2.tar.gz |
-A little More control about pixel snapping in 2D
Diffstat (limited to 'scene/2d/sprite.cpp')
-rw-r--r-- | scene/2d/sprite.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/scene/2d/sprite.cpp b/scene/2d/sprite.cpp index 87697fc073..89d9966958 100644 --- a/scene/2d/sprite.cpp +++ b/scene/2d/sprite.cpp @@ -30,6 +30,7 @@ #include "core/core_string_names.h" #include "scene/scene_string_names.h" #include "scene/main/viewport.h" +#include "os/os.h" void Sprite::edit_set_pivot(const Point2& p_pivot) { @@ -85,6 +86,9 @@ void Sprite::_notification(int p_what) { Point2 ofs=offset; if (centered) ofs-=s/2; + if (OS::get_singleton()->get_use_pixel_snap()) { + ofs=ofs.floor(); + } Rect2 dst_rect(ofs,s); @@ -422,6 +426,9 @@ void ViewportSprite::_notification(int p_what) { if (centered) ofs-=s/2; + if (OS::get_singleton()->get_use_pixel_snap()) { + ofs=ofs.floor(); + } Rect2 dst_rect(ofs,s); texture->draw_rect_region(ci,dst_rect,src_rect,modulate); |