summaryrefslogtreecommitdiff
path: root/scene/2d/camera_2d.cpp
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2016-09-15 08:17:23 -0300
committerJuan Linietsky <reduzio@gmail.com>2016-09-15 08:17:23 -0300
commit913925f10689f41ae956bb5b0b01501a8d7cf8de (patch)
tree0a0523ed751eb93e3a2586bc9fb2c5fd8731194c /scene/2d/camera_2d.cpp
parent08688931a13ee49dc435100265748e4194f081e7 (diff)
Center camera2D with the proper viewport size
Diffstat (limited to 'scene/2d/camera_2d.cpp')
-rw-r--r--scene/2d/camera_2d.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/scene/2d/camera_2d.cpp b/scene/2d/camera_2d.cpp
index 17352705c7..f33faaabd8 100644
--- a/scene/2d/camera_2d.cpp
+++ b/scene/2d/camera_2d.cpp
@@ -76,8 +76,9 @@ Matrix32 Camera2D::get_camera_transform() {
if (!get_tree())
return Matrix32();
- Size2 screen_size = get_viewport_rect().size;
- screen_size=get_viewport_rect().size;
+ ERR_FAIL_COND_V( custom_viewport && !ObjectDB::get_instance(custom_viewport_id), Matrix32() );
+
+ Size2 screen_size = viewport->get_visible_rect().size;
Point2 new_camera_pos = get_global_transform().get_origin();
@@ -446,8 +447,10 @@ void Camera2D::reset_smoothing() {
void Camera2D::align() {
- Size2 screen_size = get_viewport_rect().size;
- screen_size=get_viewport_rect().size;
+ ERR_FAIL_COND( custom_viewport && !ObjectDB::get_instance(custom_viewport_id) );
+
+ Size2 screen_size = viewport->get_visible_rect().size;
+
Point2 current_camera_pos = get_global_transform().get_origin();
if (anchor_mode==ANCHOR_MODE_DRAG_CENTER) {
if (h_ofs<0) {