Skip to content

Commit

Permalink
README update
Browse files Browse the repository at this point in the history
  • Loading branch information
Tianze Zhao committed Aug 24, 2015
1 parent 6c600ab commit 84be5ba
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,17 @@
# A-Star-PathFinder
A星寻路算法 for cocos2dx-lua

寻路的时候需要传入开始坐标,目标坐标以及存放所有地块格子的table。

1.关于地块格子(block)的划分方式
每个block为一个table
local block = {}
block.w = w --在整个地图划分中所处的行
block.h = h --在整个地图划分中所处的列
block.pos = pos --格子的中心点在地图中的坐标
block.couldCross = true --表示该格子是否是可以通过的
然后将block以键值string.format("%d_%d",block.w,block.h) 存入blocks中

2.关于路径的缓存
为了提高效率,完成一次寻路后会把相关路径信息缓存到aster.cachedPaths中,在地图变化时需要手动调用astar.clear_cached_paths清除缓存信息

0 comments on commit 84be5ba

Please sign in to comment.