Quel est le problème avec ce code?XCode 4, types incompatibles dans l'initialisation
-(float) getRotatingAngle : (CGPoint)firstPoint secondPoint:(CGPoint)secondPoint
{
float dx = firstPoint.x - secondPoint.x;
float dy = firstPoint.y - secondPoint.y;
float angle = CC_RADIANS_TO_DEGREES(atan2(dy, dx));
return angle;
}
Un lorsque je tente de l'appeler comme ceci:
float ang = [self getRotatingAngle:projectile.position secondPoint:projectile.position];
je reçois l'erreur du titre. J'utilise cocos2d (COCOS2D_VERSION 0x00010001).
Le code se trouve à l'intérieur d'un gestionnaire ccTouchesEnded
dans un CCLayerColor
.
Toute aide appréciée.
EDIT: projectile est un CCSprite
EDIT: l'erreur du compilateur est (comme dans le titre) Incompatible types in initialization. TheLayer may not respond to '-getRotatingAngle:secondPoint'
)
TRUC: C'est mon collé copie le code d'un projet cocos2d, où il a travaillé. Juste que le projet était cocos2d V2. (?)
avez-vous plus de chance si vous utilisez "' CGFloat' "et non pas" float "? –
@Michael, non, toujours la même chose. –
Mieux nous montrer comment projectile.position est déclaré. En outre, getRotatingAngle: secondPoint est-il déclaré avant d'essayer de l'invoquer? –