Drawing once per frame in Cocoa -


When I use GLUUT, I can provide a callback function which can be used to generate or animate the frame content Is called once per frame. / P>

How can I do the same thing with cocoa?

I understand that the set is Ned's display, but I do not know how to avoid calling it more than once per frame. What I need is an event or other callback that tells me how to draw another frame.

Everything in cocoa is buffer, so that you can animate and adjust the sequences without undoing them Able to do If you need to see a view as much as possible (for example, drag and repeat: Create your own animation) You need to create a timer that comes in every 1/20th position of each other And triggers the freshness of the scene.

You can create a timer like this: with Time Timer: 1.0 / 20.0 Target: Self Selector: @Selector (Animated) userInfo: Zero Repeat Is: yes];

Your callback function ("Animate" in this case) will look like this if your animation requires business logic, you should keep it here. All drawing should be done within the drawRect function of view, though.

  - Animate (zeros) {[animated view setNewsDisplay: yes]; }  

SetNews is safe to call once more Display Per Frame SetNeedsDisplay sets a flag on the scene and does not actually make any drawing. When your code is executed and returns the application to the main run loop, all the scenes will be rebuilt with setNeedsDisplay = YES.

Hope that helps!


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -