Keys ......again - Printable Version
+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Game Programming Fundamentals (/forum-7.html)
+--- Thread: Keys ......again (/thread-5922.html)
Keys ......again - Coin - Jan 29, 2005 11:52 AM
i know there are a ton of keyDown posts.. but i still cant get it to work.
down left and right i don't care about right now, but when i hit up the little error sound plays. why
Keys ......again - Josh - Jan 29, 2005 04:03 PM
Does it beep regardless of what key you hit?
Keys ......again - Coin - Jan 29, 2005 05:05 PM
yea any key i hit makes it do the click-like error sound
its pretty sad...
Keys ......again - Josh - Jan 29, 2005 06:12 PM
Your view needs to be set as the initial first responder. This can be done in IB.
Keys ......again - Coin - Jan 29, 2005 08:21 PM
i made a connection from the window to the view makeing it the initial first responder, it does the exact same thing
Keys ......again - belthaczar - Jan 29, 2005 08:39 PM
Add this to your view
Keys ......again - Coin - Jan 29, 2005 09:06 PM
thanks, that made it work better.
although it didnt need this line,
[[self window] makeFirstResponder:self];
i just added the accepts first responder part and its all good
now i know that to make it go diagonaly i have to poll for events (from reading posts at this site)
but i couldnt find accual code for how to do that.
i am guessing it meanns that it scans all the events, and does things for all the ones that are true. wouldnt that be slower and not very efficient consitering id have to make a BOOL for every event type?
Keys ......again - belthaczar - Jan 29, 2005 09:38 PM
You don't need to poll for events. The cocoa run loop does that for you and sends the interesting bits to your responder via the keyDown: and keyUp: methods. If you want to be able to handle multiple keypresses at once, you could do something like this:
and then handle all of your input in some other method that gets called periodically by an NSTimer.