1 /*************************************************************************/ 2 /* path_2d.h */ 3 /*************************************************************************/ 4 /* This file is part of: */ 5 /* GODOT ENGINE */ 6 /* https://godotengine.org */ 7 /*************************************************************************/ 8 /* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ 9 /* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ 10 /* */ 11 /* Permission is hereby granted, free of charge, to any person obtaining */ 12 /* a copy of this software and associated documentation files (the */ 13 /* "Software"), to deal in the Software without restriction, including */ 14 /* without limitation the rights to use, copy, modify, merge, publish, */ 15 /* distribute, sublicense, and/or sell copies of the Software, and to */ 16 /* permit persons to whom the Software is furnished to do so, subject to */ 17 /* the following conditions: */ 18 /* */ 19 /* The above copyright notice and this permission notice shall be */ 20 /* included in all copies or substantial portions of the Software. */ 21 /* */ 22 /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ 23 /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ 24 /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ 25 /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ 26 /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ 27 /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ 28 /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ 29 /*************************************************************************/ 30 #ifndef PATH_2D_H 31 #define PATH_2D_H 32 33 #include "scene/2d/node_2d.h" 34 #include "scene/resources/curve.h" 35 36 class Path2D : public Node2D { 37 38 OBJ_TYPE(Path2D, Node2D); 39 40 Ref<Curve2D> curve; 41 42 void _curve_changed(); 43 44 protected: 45 void _notification(int p_what); 46 static void _bind_methods(); 47 48 public: 49 void set_curve(const Ref<Curve2D> &p_curve); 50 Ref<Curve2D> get_curve() const; 51 52 Path2D(); 53 }; 54 55 class PathFollow2D : public Node2D { 56 57 OBJ_TYPE(PathFollow2D, Node2D); 58 59 public: 60 private: 61 Path2D *path; 62 real_t offset; 63 real_t h_offset; 64 real_t v_offset; 65 real_t lookahead; 66 bool cubic; 67 bool loop; 68 bool rotate; 69 70 void _update_transform(); 71 72 protected: 73 bool _set(const StringName &p_name, const Variant &p_value); 74 bool _get(const StringName &p_name, Variant &r_ret) const; 75 void _get_property_list(List<PropertyInfo> *p_list) const; 76 77 void _notification(int p_what); 78 static void _bind_methods(); 79 80 public: 81 void set_offset(float p_offset); 82 float get_offset() const; 83 84 void set_h_offset(float p_h_offset); 85 float get_h_offset() const; 86 87 void set_v_offset(float p_v_offset); 88 float get_v_offset() const; 89 90 void set_unit_offset(float p_unit_offset); 91 float get_unit_offset() const; 92 93 void set_lookahead(float p_lookahead); 94 float get_lookahead() const; 95 96 void set_loop(bool p_loop); 97 bool has_loop() const; 98 99 void set_rotate(bool p_enabled); 100 bool is_rotating() const; 101 102 void set_cubic_interpolation(bool p_enable); 103 bool get_cubic_interpolation() const; 104 105 String get_configuration_warning() const; 106 107 PathFollow2D(); 108 }; 109 110 #endif // PATH_2D_H 111