Hi. I try to call a method with a float parameter but the value the method gets is not what I sent.
Here is the code for the call (the actual call is the last part of the last line, [child setFaceDirection: direcao]; ):
direcao = dirRadianos * 180 / M_PI; // direcao = The value I send
NSLog(@"Value Sent: %f", direcao); // Log what I'm sending
for (CCNode *child in super.children) if([child respondsToSelector: @selector(setFaceDirection:)]) [child setFaceDirection: direcao];
Here is the code for the Method:
-(void) setFaceDirection: (float) angle {
NSLog(@"Value Recieved: %f", angle);
[theSprite setRotation: - angle ];
}
Here is the declaration of the float variable direcao
@interface PersControlNode : CCNode <CCTargetedTouchDelegate> {
// ...
float direcao;
// ...
}
// ...
@end
Here is the output from NSLog:
Value Sent: -16.699266
Value Recieved: 0.000000
Value Sent: -16.699301
Value Recieved: 36893488147419103232.000000
Value Sent: -16.699625
Value Recieved: -0.000000
Value Sent: 48.366463
Value Recieved: 2.000000
Value Sent: 48.366451
Value Recieved: -36893488147419103232.000000
Value Sent: 48.366428
Value Recieved: 0.000000
Value Sent: 48.366444
Value Recieved: -0.000000
Value Sent: 14.036244
Value Recieved: -0.000000
Value Sent: 14.036238
Value Recieved: -2.000000
Value Sent: 14.036201
Value Recieved: -36893488147419103232.000000
Value Sent: 14.036191
Value Recieved: -0.000000
Value Sent: 14.036273
Value Recieved: 36893488147419103232.000000
Value Sent: 12.528809
Value Recieved: 0.000000
Value Sent: 12.528766
Value Recieved: 36893488147419103232.000000
Value Sent: 12.528852
Value Recieved: -2.000000
Value Sent: 12.528863
Value Recieved: 0.000000
Value Sent: -101.309929
Value Recieved: -36893488147419103232.000000
Value Sent: -101.309860
Value Recieved: -2.000000
What am I doing wrong? I'm new to Objective C. Thanks to anyone who tries to help.
PS. It works better if I use int instead of float, but even then, there are still some errors.