Was looking around and couldn't find one that wasn't ridiculously slow...granted I didn't look to hard and I felt like trying it out. This class give you the ability to highlight a path or move a sprite along the path at a given speed.
Code:
https://github.com/sqlboy/tiled-games/tree/master/src
Quick video of path highlight option:
| Get the Video Plugin |
Code is pretty easy. Pass in a map and the name of the layer that has your collision tiles.
AStarPathFinder pathFinder = [[AStarPathFinder alloc]
initWithTileMap:tileMap collideLayer:@"collide"];
// Optionally, you can set the name of the collide property key and the value it expects.
[pathFinder setCollideKey:@"collidable"] // defaults to COLLIDE
[pathFinder setCollideValue:@"True"] // defaults to 1
// highlight a path (src and dst are tile coorindates)
[pathFinder highlightPathFrom:srcTile to:dstTile];
// move a sprite
[pathFinder moveSprite:player from:srcTile to:dstTile atSpeed:0.1f];
Enjoy and thanks to everyone for Cocos2D

