PathFindingForObjC是objc的寻路算法库,可用于iOS与OSX。内附iOS、OSX演示例子。直接gitclone或下载源码,podinstall后就可运行。
简单示例:
PathFinding *finder = [[PathFinding alloc] initWithMapSize:CGSizeMake(6, 5) tileSize:CGSizeMake(1, 1) coordsOrgin:CGPointZero];finder.heuristicType = HeuristicTypeManhattan;finder.movementType = DiagonalMovement_Never;// add blocks[finder addBlockTilePositions:@[PF_CGPointToNSValue(CGPointMake(1, 2)), PF_CGPointToNSValue(CGPointMake(2, 2)), PF_CGPointToNSValue(CGPointMake(3, 2)) ]];// set start pointfinder.startPoint = CGPointMake(2, 3);// set end pointfinder.endPoint = CGPointMake(2, 1);// get resultNSArray *foundPaths = [finder findPathing:PathfindingAlgorithm_AStar IsConvertToOriginCoords:YES];DEMOOSXDownload
iOS
评论