Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 08-15-2011, 10:06 PM   #1 (permalink)
Registered Member
 
Join Date: May 2011
Posts: 5
MZimmerman6 is on a distinguished road
Question Problem Drawing Circle in drawRect method

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!
MZimmerman6 is offline   Reply With Quote
Reply

Bookmarks

Tags
cgcontextaddarc, drawrect, ios, iphone, objective c

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 393
13 members and 380 guests
7twenty7, chiataytuday, cristofercolmbos, dedeys78, dre, fiftysixty, gmarro, jimmyon122, jonathandeknudt, pungs, raymng, tymex, UMAD
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,669
Threads: 94,121
Posts: 402,903
Top Poster: BrianSlick (7,990)
Welcome to our newest member, dedeys78
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 04:08 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0