Search code examples
androidandenginepath-findinga-startmx

AndEngine astar pathfinding


Could anyone give me an example of source code which uses astar pathfinding algorithm with AndEngine on the TMXTiledMap. I am using AndEngine downloaded from https://github.com/nicolasgramlich/AndEngine.

Any suggestion would be appreciated. Thanks!


Solution

  • This is the official TMXTiledMapExample, but it doesn't contain A* pathfinding. It can teach you about tiled maps, though.

    Here is another example from the forums which does contain it. It isn't really an example, but the pathfinding code provided there works. I don't think there is any real example of A* pathfinding, never seen any tutorial of it (The best way to learn is to read the code yourself. Better take a look at AStarPathFinder.java code).

    The important parts for you in the forum post are are (lines):

    123: Initializing the AStarPathFinder

    205 - 213: Converting screen/scene coordinates to map tiles and using the pathfinder.

    224: The method loadPathFound - using the path returned by the pathfinder to move an entity.

    The MyMap class in the third post.