summaryrefslogtreecommitdiff
path: root/scene/2d
diff options
context:
space:
mode:
Diffstat (limited to 'scene/2d')
-rw-r--r--scene/2d/animated_sprite.cpp1
-rw-r--r--scene/2d/node_2d.cpp4
-rw-r--r--scene/2d/node_2d.h2
-rw-r--r--scene/2d/physics_body_2d.cpp34
-rw-r--r--scene/2d/physics_body_2d.h3
-rw-r--r--scene/2d/sprite.cpp4
-rw-r--r--scene/2d/visibility_notifier_2d.cpp1
7 files changed, 44 insertions, 5 deletions
diff --git a/scene/2d/animated_sprite.cpp b/scene/2d/animated_sprite.cpp
index 22649cedd7..b10ee85da5 100644
--- a/scene/2d/animated_sprite.cpp
+++ b/scene/2d/animated_sprite.cpp
@@ -346,6 +346,7 @@ void AnimatedSprite::_notification(int p_what) {
update();
_change_notify("frame");
+ emit_signal(SceneStringNames::get_singleton()->frame_changed);
}
float to_process = MIN(timeout, remaining);
diff --git a/scene/2d/node_2d.cpp b/scene/2d/node_2d.cpp
index 0acc85681d..82efe1d7fb 100644
--- a/scene/2d/node_2d.cpp
+++ b/scene/2d/node_2d.cpp
@@ -243,7 +243,7 @@ void Node2D::global_translate(const Vector2 &p_amount) {
set_global_position(get_global_position() + p_amount);
}
-void Node2D::scale(const Size2 &p_amount) {
+void Node2D::apply_scale(const Size2 &p_amount) {
set_scale(get_scale() * p_amount);
}
@@ -429,7 +429,7 @@ void Node2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("move_local_y", "delta", "scaled"), &Node2D::move_y, DEFVAL(false));
ClassDB::bind_method(D_METHOD("translate", "offset"), &Node2D::translate);
ClassDB::bind_method(D_METHOD("global_translate", "offset"), &Node2D::global_translate);
- ClassDB::bind_method(D_METHOD("scale", "ratio"), &Node2D::scale);
+ ClassDB::bind_method(D_METHOD("apply_scale", "ratio"), &Node2D::apply_scale);
ClassDB::bind_method(D_METHOD("set_global_position", "pos"), &Node2D::set_global_position);
ClassDB::bind_method(D_METHOD("get_global_position"), &Node2D::get_global_position);
diff --git a/scene/2d/node_2d.h b/scene/2d/node_2d.h
index 5b3a28d5c3..df9a05ff79 100644
--- a/scene/2d/node_2d.h
+++ b/scene/2d/node_2d.h
@@ -78,7 +78,7 @@ public:
void move_y(float p_delta, bool p_scaled = false);
void translate(const Vector2 &p_amount);
void global_translate(const Vector2 &p_amount);
- void scale(const Size2 &p_amount);
+ void apply_scale(const Size2 &p_amount);
Point2 get_position() const;
float get_rotation() const;
diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp
index 8b2653f639..d5527fc9ca 100644
--- a/scene/2d/physics_body_2d.cpp
+++ b/scene/2d/physics_body_2d.cpp
@@ -798,6 +798,40 @@ bool RigidBody2D::is_contact_monitor_enabled() const {
return contact_monitor != NULL;
}
+void RigidBody2D::_notification(int p_what) {
+
+#ifdef TOOLS_ENABLED
+ if (p_what == NOTIFICATION_ENTER_TREE) {
+ if (get_tree()->is_editor_hint()) {
+ set_notify_local_transform(true); //used for warnings and only in editor
+ }
+ }
+
+ if (p_what == NOTIFICATION_LOCAL_TRANSFORM_CHANGED) {
+ if (get_tree()->is_editor_hint()) {
+ update_configuration_warning();
+ }
+ }
+
+#endif
+}
+
+String RigidBody2D::get_configuration_warning() const {
+
+ Transform2D t = get_transform();
+
+ String warning = CollisionObject2D::get_configuration_warning();
+
+ if ((get_mode() == MODE_RIGID || get_mode() == MODE_CHARACTER) && (ABS(t.elements[0].length() - 1.0) > 0.05 || ABS(t.elements[1].length() - 1.0) > 0.05)) {
+ if (warning != String()) {
+ warning += "\n";
+ }
+ warning += TTR("Size changes to RigidBody2D (in character or rigid modes) will be overriden by the physics engine when running.\nChange the size in children collision shapes instead.");
+ }
+
+ return warning;
+}
+
void RigidBody2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_mode", "mode"), &RigidBody2D::set_mode);
diff --git a/scene/2d/physics_body_2d.h b/scene/2d/physics_body_2d.h
index 8c8e4ebc77..54bd263b15 100644
--- a/scene/2d/physics_body_2d.h
+++ b/scene/2d/physics_body_2d.h
@@ -185,6 +185,7 @@ private:
bool _test_motion(const Vector2 &p_motion, float p_margin = 0.08, const Ref<Physics2DTestMotionResult> &p_result = Ref<Physics2DTestMotionResult>());
protected:
+ void _notification(int p_what);
static void _bind_methods();
public:
@@ -253,6 +254,8 @@ public:
Array get_colliding_bodies() const; //function for script
+ virtual String get_configuration_warning() const;
+
RigidBody2D();
~RigidBody2D();
};
diff --git a/scene/2d/sprite.cpp b/scene/2d/sprite.cpp
index ad34dfd63a..01d101a89c 100644
--- a/scene/2d/sprite.cpp
+++ b/scene/2d/sprite.cpp
@@ -237,7 +237,7 @@ void Sprite::set_vframes(int p_amount) {
vframes = p_amount;
update();
item_rect_changed();
- _change_notify("frame");
+ _change_notify();
}
int Sprite::get_vframes() const {
@@ -250,7 +250,7 @@ void Sprite::set_hframes(int p_amount) {
hframes = p_amount;
update();
item_rect_changed();
- _change_notify("frame");
+ _change_notify();
}
int Sprite::get_hframes() const {
diff --git a/scene/2d/visibility_notifier_2d.cpp b/scene/2d/visibility_notifier_2d.cpp
index a37c74cb07..fb71b61d45 100644
--- a/scene/2d/visibility_notifier_2d.cpp
+++ b/scene/2d/visibility_notifier_2d.cpp
@@ -33,6 +33,7 @@
#include "scene/2d/animated_sprite.h"
#include "scene/2d/physics_body_2d.h"
#include "scene/animation/animation_player.h"
+#include "scene/main/viewport.h"
#include "scene/scene_string_names.h"
#include "scene/scene_string_names.h"