Re: Modal event processing
Re: Modal event processing
- Subject: Re: Modal event processing
- From: Graham Cox <email@hidden>
- Date: Sat, 07 Jul 2012 00:13:43 +1000
On 06/07/2012, at 11:38 PM, Charlie Dickman wrote:
> I'll have to re-architect the app.
Maybe.
The thing that's key is that you do not run the event loop - it runs you (we're in Soviet Russia now). It also runs any timers which are attached to it. Timers do not (and can not) run the event loop - it's the other way around.
Any time you feel tempted to "force" the event loop to run you have a big red flag (Russia again?) telling you something is wrong. If you look at the starter app that is created by Xcode, you will see no visible code that runs an event loop, but controls and menus you add to the basic xib work just fine.
In the case of a game, if you have designed it so that the pieces can be moved by the user manually, adding automation shouldn't be too hard. You can use a timer to invoke movements at a lower level, just as the mouse events call down to cause movement at the same lower level. (With Core Animation and using a CALayer for each of the pieces, doing this with animation should be really easy, though the setup with CA would take a bit more time - look at the GeekGameBoard sample code, it's probably 90% of the necessary game mechanics as it is).
--Graham
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden