diff options
author | Kanabenki <18357657+Kanabenki@users.noreply.github.com> | 2019-04-08 11:14:10 +0200 |
---|---|---|
committer | Kanabenki <18357657+Kanabenki@users.noreply.github.com> | 2019-04-08 11:29:13 +0200 |
commit | 714953b3ac697f0925c740581880cb71e2f94777 (patch) | |
tree | 3d906160c48f40ffedd912163db4f966c5a820de /scene/2d/line_2d.cpp | |
parent | 5a64c679cfc5463afd4a703b1c6e437d894b22b1 (diff) |
Add optional position argument for add_point in Line2D
Diffstat (limited to 'scene/2d/line_2d.cpp')
-rw-r--r-- | scene/2d/line_2d.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/scene/2d/line_2d.cpp b/scene/2d/line_2d.cpp index 73692e0535..ba06b3ebff 100644 --- a/scene/2d/line_2d.cpp +++ b/scene/2d/line_2d.cpp @@ -120,8 +120,12 @@ void Line2D::clear_points() { } } -void Line2D::add_point(Vector2 pos) { - _points.append(pos); +void Line2D::add_point(Vector2 pos, int atpos) { + if (atpos < 0 || _points.size() < atpos) { + _points.append(pos); + } else { + _points.insert(atpos, pos); + } update(); } @@ -318,7 +322,7 @@ void Line2D::_bind_methods() { ClassDB::bind_method(D_METHOD("get_point_count"), &Line2D::get_point_count); - ClassDB::bind_method(D_METHOD("add_point", "position"), &Line2D::add_point); + ClassDB::bind_method(D_METHOD("add_point", "position", "at_position"), &Line2D::add_point, DEFVAL(-1)); ClassDB::bind_method(D_METHOD("remove_point", "i"), &Line2D::remove_point); ClassDB::bind_method(D_METHOD("clear_points"), &Line2D::clear_points); |