i essayer de retourner un CGPoint mais je fais quelque chose de mal:CGPoint méthode retour
Voici ma méthode:
- (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);
}
Le code dans la méthode fonctionne très bien, mais je fais quelque chose de mal à l'initialisation.
Ici j'appelle la méthode:
point1.position = [self calculatePointOnCircleFrom:Player.position PointB:touchPos radius:64];
et obtenir erreur duper: "type incompatible pour l'argument 1 de 'setPosition:'"
oui, je pense que si je fais: " point1.position = CGPointMake (200 200); " Ça marche. – Mario