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