Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Newbie Cocoa Question:

Newbie Cocoa Question:
Thread Tools
Mac Enthusiast
Join Date: Jan 2001
Status: Offline
Reply With Quote
May 1, 2001, 07:52 PM
 
lets say i have a function that increments the size of a circle from 1 to 100...

so i have my function:

- (void)startGame id)sender {
for(x = 10 ; x < 100 ; x++) {
//x is the size of the circle
[self setNeedsDisplay:YES];
}
}

How do I tell is to pause for like 0.1 seconds so it can redraw, because right now, it jumps from 1 to 100 instantaneously. Is there a sleep function like in Java?


Thanks for your help


ALSO: Is it possible to draw a semitransparent object like a circle?

[This message has been edited by 00101001 (edited 05-01-2001).]
     
Mac Elite
Join Date: Sep 2000
Location: Eagan, MN
Status: Offline
Reply With Quote
May 1, 2001, 08:46 PM
 
The proper way would be to start an NSTimer to fire that method every .1 seconds.

------------------
     
Mac Enthusiast
Join Date: Jan 2001
Status: Offline
Reply With Quote
May 1, 2001, 09:04 PM
 
Thanks for the tip, ill try that now.
How about drawing semitransparent stuff though?
I looked through the manuals, and couldn't really figure it out (im rather new at this stuff)

Thanks!
     
Admin Emeritus
Join Date: Oct 2000
Location: Boston, MA
Status: Offline
Reply With Quote
May 1, 2001, 09:51 PM
 
If you wanted to set the color (with an alpha), use NSColor's colorWithCalibratedRGB(red, green, blue, alpha) and set() functions, then draw the oval.
"Against stupidity, the gods themselves contend in vain" (Schiller)
     
Mac Enthusiast
Join Date: Jan 2001
Status: Offline
Reply With Quote
May 1, 2001, 09:59 PM
 
Sorry, im new...
this is how I think I know how to do it:
[[NSColor colorWithCalibratedRGB:0.5:0.5:0.5:0.5] set];

but when I compile it gives me:

cannot find class (factory) method.
return type for 'colorWithCalibratedRGB::::' defaults to id

what am I doing wrong?
     
Mac Elite
Join Date: Sep 2000
Location: Eagan, MN
Status: Offline
Reply With Quote
May 1, 2001, 11:02 PM
 
Originally posted by 00101001:
Sorry, im new...
this is how I think I know how to do it:
[[NSColor colorWithCalibratedRGB:0.5:0.5:0.5:0.5] set];
It should be like this:

[[NSColor colorWithCalibratedRed:0.5 green:0.5 blue:0.5 alpha:0.5] set];

------------------
     
Admin Emeritus
Join Date: Oct 2000
Location: Boston, MA
Status: Offline
Reply With Quote
May 2, 2001, 06:18 AM
 
Oh, heh. I just saw "Java" in your post and assumed you were using Java. Maybe I should read more carefully next time :-)
"Against stupidity, the gods themselves contend in vain" (Schiller)
     
Mac Enthusiast
Join Date: Jan 2001
Status: Offline
Reply With Quote
May 2, 2001, 05:01 PM
 
SWEET!!!!
thanks for your help.

Next step: porting my 3D engine to Cocoa, stay tuned!
     
   
Thread Tools
Forum Links
Forum 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
Top
Privacy Policy
All times are GMT -5. The time now is 09:54 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2