I am having some trouble drawing a circle in my drawRect view. I am trying to create a ball that bounces around the screen and interacts with other things. So the ball contains all of the information, like position, velocity, and all of that stuff. That is not the problem though. The problem comes in when I go to draw the circle. I am using the following code
Code:
[[UIColor greenColor] set];
Ball *temp = [balls objectAtIndex:0];
CGFloat xVal = [temp position].x;
CGFloat yVal = [temp position].y;
NSLog(@"%f,%f",xVal,yVal);
CGContextBeginPath(context);
CGContextAddArc(context, xVal, yVal, 5, 0, 2*M_PI, 0);
CGContextFillPath(context);
When I do this the circle will draw, but it will draw with an origin at point 0,0. I know xVal and yVal are correct just from looking at the NSLog statements.
I can go and hard code in a value as in the second code block and it will draw at the entered point, but I do not want the ball to stay in the same spot.
Code:
[[UIColor greenColor] set];
CGContextBeginPath(context);
CGContextAddArc(context, 20, 20, 5, 0, 2*M_PI, 0);
CGContextFillPath(context);
Oh also, drawrect is being call in a runloop so the stuff is being update every 1/30 seconds.
Does anyone have any suggestions or know of a known error for this? I have tried casting it to every type such as double, int, float, whatever, with no success.
Thanks in advance for any help!