Monday, 27 October 2014

Distance between two points in cocos2d

Distance between two points in cocos2d


CGPoint beforePoint,afterPoint;
CGFloat xDist = (beforePoint.x - afterPoint.x);
CGFloat yDist = (beforePoint.y - afterPoint.y);
CGFloat distance = sqrt((xDist * xDist) + (yDist * yDist));

CCLOG(@"distance is %f",distance);




No comments:

Post a Comment