diff options
Diffstat (limited to 'scene/2d')
-rw-r--r-- | scene/2d/camera_2d.cpp | 24 | ||||
-rw-r--r-- | scene/2d/camera_2d.h | 4 | ||||
-rw-r--r-- | scene/2d/particles_2d.cpp | 32 | ||||
-rw-r--r-- | scene/2d/particles_2d.h | 8 | ||||
-rw-r--r-- | scene/2d/screen_button.cpp | 4 |
5 files changed, 70 insertions, 2 deletions
diff --git a/scene/2d/camera_2d.cpp b/scene/2d/camera_2d.cpp index 1920ce0081..acae3e62c4 100644 --- a/scene/2d/camera_2d.cpp +++ b/scene/2d/camera_2d.cpp @@ -134,6 +134,11 @@ Matrix32 Camera2D::get_camera_transform() { Point2 screen_offset = (centered ? (screen_size * 0.5 * zoom) : Point2());;
screen_offset+=offset;
+ float angle = get_global_transform().get_rotation();
+ if(rotating){
+ screen_offset = screen_offset.rotated(angle);
+ }
+
Rect2 screen_rect(-screen_offset+ret_camera_pos,screen_size);
if (screen_rect.pos.x + screen_rect.size.x > limit[MARGIN_RIGHT])
screen_rect.pos.x = limit[MARGIN_RIGHT] - screen_rect.size.x;
@@ -151,6 +156,9 @@ Matrix32 Camera2D::get_camera_transform() { camera_screen_center=screen_rect.pos+screen_rect.size*0.5;
Matrix32 xform;
+ if(rotating){
+ xform.set_rotation(angle);
+ }
xform.scale_basis(zoom);
xform.set_origin(screen_rect.pos/*.floor()*/);
@@ -251,6 +259,17 @@ bool Camera2D::is_centered() const { return centered;
}
+void Camera2D::set_rotating(bool p_rotating){
+
+ rotating=p_rotating;
+ _update_scroll();
+}
+
+bool Camera2D::is_rotating() const {
+
+ return rotating;
+}
+
void Camera2D::_make_current(Object *p_which) {
@@ -394,6 +413,9 @@ void Camera2D::_bind_methods() { ObjectTypeDB::bind_method(_MD("set_centered","centered"),&Camera2D::set_centered);
ObjectTypeDB::bind_method(_MD("is_centered"),&Camera2D::is_centered);
+ ObjectTypeDB::bind_method(_MD("set_rotating","rotating"),&Camera2D::set_rotating);
+ ObjectTypeDB::bind_method(_MD("is_rotating"),&Camera2D::is_rotating);
+
ObjectTypeDB::bind_method(_MD("make_current"),&Camera2D::make_current);
ObjectTypeDB::bind_method(_MD("_make_current"),&Camera2D::_make_current);
@@ -436,6 +458,7 @@ void Camera2D::_bind_methods() { ADD_PROPERTYNZ( PropertyInfo(Variant::VECTOR2,"offset"),_SCS("set_offset"),_SCS("get_offset"));
ADD_PROPERTY( PropertyInfo(Variant::BOOL,"centered"),_SCS("set_centered"),_SCS("is_centered"));
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"rotating"),_SCS("set_rotating"),_SCS("is_rotating"));
ADD_PROPERTY( PropertyInfo(Variant::BOOL,"current"),_SCS("_set_current"),_SCS("is_current"));
ADD_PROPERTY( PropertyInfo(Variant::REAL,"smoothing"),_SCS("set_follow_smoothing"),_SCS("get_follow_smoothing") );
ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"zoom"),_SCS("set_zoom"),_SCS("get_zoom") );
@@ -462,6 +485,7 @@ Camera2D::Camera2D() { centered=true;
+ rotating=false;
current=false;
limit[MARGIN_LEFT]=-10000000;
limit[MARGIN_TOP]=-10000000;
diff --git a/scene/2d/camera_2d.h b/scene/2d/camera_2d.h index 9d06df2d1b..116169cac1 100644 --- a/scene/2d/camera_2d.h +++ b/scene/2d/camera_2d.h @@ -50,6 +50,7 @@ protected: Vector2 offset;
Vector2 zoom;
bool centered;
+ bool rotating;
bool current;
float smoothing;
int limit[4];
@@ -79,6 +80,9 @@ public: void set_centered(bool p_centered);
bool is_centered() const;
+ void set_rotating(bool p_rotating);
+ bool is_rotating() const;
+
void set_limit(Margin p_margin,int p_limit);
int get_limit(Margin p_margin) const;
diff --git a/scene/2d/particles_2d.cpp b/scene/2d/particles_2d.cpp index c10f60f78b..3d7aa58c6d 100644 --- a/scene/2d/particles_2d.cpp +++ b/scene/2d/particles_2d.cpp @@ -880,6 +880,26 @@ float Particles2D::get_explosiveness() const{ return explosiveness; } +void Particles2D::set_flip_h(bool p_flip) { + + flip_h=p_flip; +} + +bool Particles2D::is_flipped_h() const{ + + return flip_h; +} + +void Particles2D::set_flip_v(bool p_flip){ + + flip_v=p_flip; +} +bool Particles2D::is_flipped_v() const{ + + return flip_v; +} + + void Particles2D::set_emission_points(const DVector<Vector2>& p_points) { emission_points=p_points; @@ -922,6 +942,12 @@ void Particles2D::_bind_methods() { ObjectTypeDB::bind_method(_MD("set_emissor_offset","offset"),&Particles2D::set_emissor_offset); ObjectTypeDB::bind_method(_MD("get_emissor_offset"),&Particles2D::get_emissor_offset); + ObjectTypeDB::bind_method(_MD("set_flip_h","enable"),&Particles2D::set_flip_h); + ObjectTypeDB::bind_method(_MD("is_flipped_h"),&Particles2D::is_flipped_h); + + ObjectTypeDB::bind_method(_MD("set_flip_v","enable"),&Particles2D::set_flip_v); + ObjectTypeDB::bind_method(_MD("is_flipped_v"),&Particles2D::is_flipped_v); + ObjectTypeDB::bind_method(_MD("set_emission_half_extents","extents"),&Particles2D::set_emission_half_extents); ObjectTypeDB::bind_method(_MD("get_emission_half_extents"),&Particles2D::get_emission_half_extents); @@ -958,6 +984,8 @@ void Particles2D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::VECTOR2,"config/half_extents"),_SCS("set_emission_half_extents"),_SCS("get_emission_half_extents")); ADD_PROPERTY(PropertyInfo(Variant::BOOL,"config/local_space"),_SCS("set_use_local_space"),_SCS("is_using_local_space")); ADD_PROPERTY(PropertyInfo(Variant::REAL,"config/explosiveness",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_explosiveness"),_SCS("get_explosiveness")); + ADD_PROPERTY(PropertyInfo(Variant::BOOL,"config/flip_h"),_SCS("set_flip_h"),_SCS("is_flipped_h")); + ADD_PROPERTY(PropertyInfo(Variant::BOOL,"config/flip_v"),_SCS("set_flip_v"),_SCS("is_flipped_v")); ADD_PROPERTY(PropertyInfo(Variant::OBJECT,"config/texture",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_texture"),_SCS("get_texture")); @@ -1039,6 +1067,10 @@ Particles2D::Particles2D() { set_color_phase_color(2,Color(0,0,0)); set_color_phase_color(3,Color(0,0,0)); + flip_h=false; + flip_v=false; + + emit_timeout = 0; time_to_live = 0; explosiveness=1.0; diff --git a/scene/2d/particles_2d.h b/scene/2d/particles_2d.h index 8849149127..f562e826e0 100644 --- a/scene/2d/particles_2d.h +++ b/scene/2d/particles_2d.h @@ -143,6 +143,8 @@ private: float emit_timeout; float time_to_live; float time_scale; + bool flip_h; + bool flip_v; Point2 emissor_offset; Vector2 initial_velocity; Vector2 extents; @@ -197,6 +199,12 @@ public: void set_explosiveness(float p_value); float get_explosiveness() const; + void set_flip_h(bool p_flip); + bool is_flipped_h() const; + + void set_flip_v(bool p_flip); + bool is_flipped_v() const; + void set_color_phases(int p_phases); int get_color_phases() const; diff --git a/scene/2d/screen_button.cpp b/scene/2d/screen_button.cpp index f386dc63e8..871c351479 100644 --- a/scene/2d/screen_button.cpp +++ b/scene/2d/screen_button.cpp @@ -155,7 +155,7 @@ void TouchScreenButton::_input(const InputEvent& p_event) { if (finger_pressed==-1 || p_event.screen_touch.index==finger_pressed) { - Point2 coord = (get_viewport_transform() * get_global_transform()).affine_inverse().xform(Point2(p_event.screen_touch.x,p_event.screen_touch.y)); + Point2 coord = (get_global_transform()).affine_inverse().xform(Point2(p_event.screen_touch.x,p_event.screen_touch.y)); bool touched=false; if (bitmask.is_valid()) { @@ -231,7 +231,7 @@ void TouchScreenButton::_input(const InputEvent& p_event) { if (finger_pressed!=-1) return; //already fingering - Point2 coord = (get_viewport_transform() * get_global_transform()).affine_inverse().xform(Point2(p_event.screen_touch.x,p_event.screen_touch.y)); + Point2 coord = (get_global_transform()).affine_inverse().xform(Point2(p_event.screen_touch.x,p_event.screen_touch.y)); bool touched=false; if (bitmask.is_valid()) { |