FAStarBase.find_path
声明
public array find_path(int startx, int starty, int endx, int endy)
参数
参数名 | 描述 |
---|---|
startx | 起点横坐标 |
starty | 起点纵坐标 |
endx | 终点横坐标 |
endy | 终点纵坐标 |
作用
该接口用来进行寻路,获取一个起点到终点的路径
使用方式
map.gs
component pkg.astar.components.FAStarBase;
void create(array para)
{
this.init_map(para);
}
test.gs
array grids =
[
[0, 0, 0, 0, 1, 1, 0, 1, 0, 1],
[1, 0, 0, 0, 1, 1, 0, 1, 0, 1],
[1, 1, 0, 0, 1, 1, 0, 1, 0, 1],
[1, 1, 1, 0, 1, 1, 0, 1, 0, 1],
[0, 1, 0, 0, 1, 1, 0, 1, 0, 1],
[1, 0, 1, 0, 0, 0, 0, 1, 0, 1],
[0, 0, 0, 0, 1, 1, 0, 0, 0, 1],
[0, 0, 0, 0, 1, 1, 1, 1, 0, 1],
[0, 0, 0, 0, 1, 1, 0, 1, 0, 1],
[0, 0, 0, 0, 1, 1, 1, 0, 1, 1],
];
object m = new_object(map, this_domain(), grids);
write(m.find_path(0, 0, 4, 0));