summaryrefslogtreecommitdiff
path: root/scene/2d
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2015-10-13 15:53:34 -0300
committerJuan Linietsky <reduzio@gmail.com>2015-10-13 15:53:34 -0300
commit79e5ced7e668fa53567ac6aaf5a26393cea6c9a2 (patch)
treef2c575f1957ab443eef49598f6f46c4285b4450c /scene/2d
parentb3cda43a0fb49e1cb9c8414077a23fa4b61ede38 (diff)
-A little More control about pixel snapping in 2D
Diffstat (limited to 'scene/2d')
-rw-r--r--scene/2d/animated_sprite.cpp5
-rw-r--r--scene/2d/sprite.cpp7
2 files changed, 12 insertions, 0 deletions
diff --git a/scene/2d/animated_sprite.cpp b/scene/2d/animated_sprite.cpp
index 0b00ac9560..342b86b4c1 100644
--- a/scene/2d/animated_sprite.cpp
+++ b/scene/2d/animated_sprite.cpp
@@ -28,6 +28,8 @@
/*************************************************************************/
#include "animated_sprite.h"
#include "scene/scene_string_names.h"
+#include "os/os.h"
+
void AnimatedSprite::edit_set_pivot(const Point2& p_pivot) {
set_offset(p_pivot);
@@ -153,6 +155,9 @@ void AnimatedSprite::_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);
if (hflip)
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);