When to run event loop...

⌘-R in Chief
Posts: 1,261
Joined: 2002.05
Post: #1
I'm writing a game engine that takes over the whole screen so no standard UI elements are seen. As in any game, I want to show some company logo movies, a game intro movie, and then the main menu for the game. The question is, when do you call RunApplicationEventLoop? Or should I not in a game?

I was thinking that in a setup routine you'd load up the first movie, set a callback for when the movie is done and the call RunAppEventLoop. When the callback is fired you call the next movie with another callback etc... until you're done with the movies. When the last movie's 'finished' callbac is done, you load the main menu with custom controls (which I need to ask about) and install event handlers to handle the interactions.

Is this an okay way to do it?
Quote this message in a reply
kainsin
Unregistered
 
Post: #2
The only requirement is that you need to run the event loop before main exits. Otherwise your application will quit. Smile

You method seems fine, just as long as everything works as it is supposed to. Don't forget that you can have more than just one event loop. You can have, for instance, 'Initial screen event loop' that knows what all of the controls are in the opening screen and 'Game event loop' that knows what to do when certain keys are pressed while in the game.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #3
Sounds good. It also means you'll be able to trap key presses, mouse clicks, &c so that the user can skip the movies if they want.
Quote this message in a reply
ededed
Unregistered
 
Post: #4
I think you should just do it all like a normal cocoa NSView thing. You will still be able to do it fullscreen but it will allow a windowed option, you will be able to hide the cursor ([NSCursor hide], [NSCursor unhide]) and you can lock the mouse to have you own custom cursor (i.e a cursor that mouse in a funny way or with a ceartain sensitivity).
You can use OpenGL with a cocoa application without using glut (GLCubes is a good example). And you can use quicktime to play movies. You should be able to do all the custom interface stuff very easily with that system.

Good luck.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Starting Menu: a separate event loop? ferum 11 5,654 Sep 8, 2006 03:35 AM
Last Post: imikedaman
  Cocoa Event Loop/NSTimer revisited Fenris 6 5,419 Oct 29, 2005 11:27 PM
Last Post: maaaaark