| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
#pragma once |
| 32 |
|
| 33 |
#include "scene/2d/node_2d.h" |
| 34 |
|
| 35 |
class Parallax2D : public Node2D { |
| 36 |
GDCLASS(Parallax2D, Node2D); |
| 37 |
|
| 38 |
static constexpr real_t DEFAULT_LIMIT = 10000000; |
| 39 |
|
| 40 |
String group_name; |
| 41 |
Size2 scroll_scale = Size2(1, 1); |
| 42 |
Point2 scroll_offset; |
| 43 |
Point2 screen_offset; |
| 44 |
Vector2 repeat_size; |
| 45 |
int repeat_times = 1; |
| 46 |
Point2 limit_begin = Point2(-DEFAULT_LIMIT, -DEFAULT_LIMIT); |
| 47 |
Point2 limit_end = Point2(DEFAULT_LIMIT, DEFAULT_LIMIT); |
| 48 |
Point2 autoscroll; |
| 49 |
bool follow_viewport = true; |
| 50 |
bool ignore_camera_scroll = false; |
| 51 |
|
| 52 |
void _update_process(); |
| 53 |
void _update_repeat(); |
| 54 |
void _update_scroll(); |
| 55 |
|
| 56 |
protected: |
| 57 |
#ifdef TOOLS_ENABLED |
| 58 |
void _edit_set_position(const Point2 &p_position) override; |
| 59 |
#endif |
| 60 |
void _validate_property(PropertyInfo &p_property) const; |
| 61 |
void _camera_moved(const Transform2D &p_transform, const Point2 &p_screen_offset, const Point2 &p_adj_screen_offset); |
| 62 |
void _notification(int p_what); |
| 63 |
static void _bind_methods(); |
| 64 |
|
| 65 |
public: |
| 66 |
void set_scroll_scale(const Size2 &p_scale); |
| 67 |
Size2 get_scroll_scale() const; |
| 68 |
|
| 69 |
void set_repeat_size(const Size2 &p_repeat_size); |
| 70 |
Size2 get_repeat_size() const; |
| 71 |
|
| 72 |
void set_repeat_times(int p_repeat_times); |
| 73 |
int get_repeat_times() const; |
| 74 |
|
| 75 |
void set_autoscroll(const Point2 &p_autoscroll); |
| 76 |
Point2 get_autoscroll() const; |
| 77 |
|
| 78 |
void set_scroll_offset(const Point2 &p_offset); |
| 79 |
Point2 get_scroll_offset() const; |
| 80 |
|
| 81 |
void set_screen_offset(const Point2 &p_offset); |
| 82 |
Point2 get_screen_offset() const; |
| 83 |
|
| 84 |
void set_limit_begin(const Point2 &p_offset); |
| 85 |
Point2 get_limit_begin() const; |
| 86 |
|
| 87 |
void set_limit_end(const Point2 &p_offset); |
| 88 |
Point2 get_limit_end() const; |
| 89 |
|
| 90 |
void set_follow_viewport(bool p_follow); |
| 91 |
bool get_follow_viewport(); |
| 92 |
|
| 93 |
void set_ignore_camera_scroll(bool p_ignore); |
| 94 |
bool is_ignore_camera_scroll(); |
| 95 |
|
| 96 |
Parallax2D(); |
| 97 |
}; |