Attention: Here be dragons
This is the latest
(unstable) version of this documentation, which may document features
not available in or compatible with released stable versions of Godot.
Checking the stable version of the documentation...
PolygonPathFinder
继承: Resource < RefCounted < Object
该类目前没有描述,请帮我们贡献一个吧!
方法
get_bounds() const |
|
get_closest_point(point: Vector2) const |
|
get_intersections(from: Vector2, to: Vector2) const |
|
get_point_penalty(idx: int) const |
|
is_point_inside(point: Vector2) const |
|
void |
set_point_penalty(idx: int, penalty: float) |
void |
setup(points: PackedVector2Array, connections: PackedInt32Array) |
方法说明
PackedVector2Array find_path(from: Vector2, to: Vector2) 🔗
该方法目前没有描述,请帮我们贡献一个吧!
该方法目前没有描述,请帮我们贡献一个吧!
Vector2 get_closest_point(point: Vector2) const 🔗
该方法目前没有描述,请帮我们贡献一个吧!
PackedVector2Array get_intersections(from: Vector2, to: Vector2) const 🔗
该方法目前没有描述,请帮我们贡献一个吧!
float get_point_penalty(idx: int) const 🔗
该方法目前没有描述,请帮我们贡献一个吧!
bool is_point_inside(point: Vector2) const 🔗
如果 point
在多边形区域内部,则返回 true
。
var polygon_path_finder = PolygonPathFinder.new()
var points = [Vector2(0.0, 0.0), Vector2(1.0, 0.0), Vector2(0.0, 1.0)]
var connections = [0, 1, 1, 2, 2, 0]
polygon_path_finder.setup(points, connections)
print(polygon_path_finder.is_point_inside(Vector2(0.2, 0.2))) # 输出 true
print(polygon_path_finder.is_point_inside(Vector2(1.0, 1.0))) # 输出 false
var polygonPathFinder = new PolygonPathFinder();
Vector2[] points =
[
new Vector2(0.0f, 0.0f),
new Vector2(1.0f, 0.0f),
new Vector2(0.0f, 1.0f)
];
int[] connections = [0, 1, 1, 2, 2, 0];
polygonPathFinder.Setup(points, connections);
GD.Print(polygonPathFinder.IsPointInside(new Vector2(0.2f, 0.2f))); // 输出 True
GD.Print(polygonPathFinder.IsPointInside(new Vector2(1.0f, 1.0f))); // 输出 False
void set_point_penalty(idx: int, penalty: float) 🔗
该方法目前没有描述,请帮我们贡献一个吧!
void setup(points: PackedVector2Array, connections: PackedInt32Array) 🔗
使用两个数组设置 PolygonPathFinder:点数组中定义了多边形的顶点,索引数组则决定了多边形的边。
connections
的长度必须为偶数,为奇数时会返回错误。
var polygon_path_finder = PolygonPathFinder.new()
var points = [Vector2(0.0, 0.0), Vector2(1.0, 0.0), Vector2(0.0, 1.0)]
var connections = [0, 1, 1, 2, 2, 0]
polygon_path_finder.setup(points, connections)
var polygonPathFinder = new PolygonPathFinder();
Vector2[] points =
[
new Vector2(0.0f, 0.0f),
new Vector2(1.0f, 0.0f),
new Vector2(0.0f, 1.0f)
];
int[] connections = [0, 1, 1, 2, 2, 0];
polygonPathFinder.Setup(points, connections);