开发者

Mac Dev - How to refresh view for 2d game?

If you see 开发者_StackOverflowmy other question, you'll know that I'm starting to try making simple 2d games on mac. There I was deciding which library to use (OpenGL or Quartz), but no matter what I'll have to use Cocoa to make it a nice Mac application, and for the window and the view (with OpenGL, NSOpenGLView). Obviously for a game, the view will have to redraw many times per second. To make a view redraw, you need to do [view setNeedsDisplay:YES];, but I read that you shouldn't do this many times (because it costs a lot). But how am I supposed to redraw the view e.g. at a reasonable fps for a 2d game? Thanks.


The "only redraw if you have to" rule doesn't really apply to games. Games usually try to redraw at the refresh rate of the monitor, or as close to that rate as possible.

This page describes how to make on OpenGL rendering loop in cocoa: http://developer.apple.com/mac/library/qa/qa2004/qa1385.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜