问题描述:

The following code:

CGFloat currentDistance = distanceBetweenPoints(firstTouch,secondTouch);

gives me this error: Implicit declaration of 'distanceBetweenPoints' is invalid in C99

firstTouch and secondTouch are CGPoints

 CGPoint firstTouch = [tOne locationInView:[tOne view]];

CGPoint secondTouch = [tTwo locationInView:[tTwo view]];

How do I get rid of this error?

网友答案:

I suppose you're using a very old version of Cocos2D? I only know this method by the name of ccpDistance. See: http://learn-cocos2d.com/api-ref/latest/cocos2d-iphone/html/_c_g_point_extension_8h.html#a76b1b389db811d00e0a461df630d9a8e

网友答案:

Make sure you have:

#include "CGPointUtils.h"

somewhere in your source file before you try to call distanceBetweenPoints.

相关阅读:
Top