i try to return a CGPoint but i do something wrong:
Here is my method:
- (CGPoint)calculatePointOnCircleFrom:(CGPoint)pointA PointB:(CGPoint)pointB radius:(float)rd {
float sryy = pointA.y - pointB.y;
float srxx = pointA.x - pointB.x;
float sry = pointA.y + sryy;
float srx = pointA.x + srxx;
float kpx = pointA.x + cos(atan2(pointA.y - sry, pointA.x - srx)) * rd;
float kpy = pointA.y + sin(atan2(pointA.y - sry, pointA.x - srx)) * rd;
return CGPointMake(kpx, kpy);
}
The code in the method works fine but i do something wrong with the initialization.
Here i call the method:
point1.position = [self calculatePointOnCircleFrom:Player.position PointB:touchPos radius:64];
and get fooling error: “incompatible type for argument 1 of ‘setPosition:'”
There’s probably also a warning that it can’t find the method declaration. It sounds like the compiler doesn’t know what type the method returns and is defaulting to id.