CB Key handling

Moderator
Posts: 916
Joined: 2002.10
Post: #1
question for others out there using CocoaBlitz. I am having trouble handling keys. Could you happen to post how you set it up for your game to handle keys? Looking at the layering and and naming project has not helped me much.
Quote this message in a reply
Moderator
Posts: 608
Joined: 2002.04
Post: #2
Are you subclassing CBView? I am using an old version but that works for me.
Quote this message in a reply
Member
Posts: 469
Joined: 2002.10
Post: #3
make your object a delegate of the CBView and implement -viewDidReceiveEvent: to get keys. If you need a step by step, ask skyhawk who now knows how. I'll probably get around to making a tutorial doc sometime this week.

---Kelvin--
15.4" MacBook Pro revA
1.83GHz/2GB/250GB
Quote this message in a reply
Moderator
Posts: 608
Joined: 2002.04
Post: #4
I might need a walkthrough once I get around to using the new CB version.

On a related side note, I really can't wait to see how Kelvin and Brian's games turn out. A real test for CB, not to mention the spiffy source we will get out of it. Love
Quote this message in a reply
Member
Posts: 469
Joined: 2002.10
Post: #5
Quote:Originally posted by jabber
I might need a walkthrough once I get around to using the new CB version.

On a related side note, I really can't wait to see how Kelvin and Brian's games turn out. A real test for CB, not to mention the spiffy source we will get out of it. Love


Included with the current download is a naming and layering demo. This demo does key handling in the AppController/CBViewdelegete. Look for the spacebar machine gun.

---Kelvin--
15.4" MacBook Pro revA
1.83GHz/2GB/250GB
Quote this message in a reply
PuppyHelmet
Unregistered
 
Post: #6
I'm going to be using CB for my uDG entry. I'm getting the hang of how the object model works (elegant in its simplicity!) but I'm not sure what everyone means by the word "delegate," which I've heard and seen a lot in the CB threads. What does it mean for an object to be a delegate of a class? Is that a different way of saying it extends that class, or does it mean more literally that all the responsibility for handling the class gets "delegated" to that object?

I'm also new to Obj-C, so if it's part of the Cocoa way of life I'd be glad to know more about it.

Thanks,
- Chris
Quote this message in a reply
Member
Posts: 469
Joined: 2002.10
Post: #7
delegate objects are basically just objects that handle events and actions for other objects. For instance, subclassing NSApplication is a bit much just to get some functionality like quitting after the last window closes. Delegates can handle situations for the objects without having to a mass huge complicated spaghetti objects.

In CocoaBlitz if you subclassed CBCell every time you wanted a new game element you'd have an unmanageable pile of CBCell subclasses. Furthermore you wouldn't be able to change the behavior of any one element once it was instantiated. Having a delegate allows you to have a smaller piece of code make the CBCell behave as you want it to and also let you change the behavior (by changing the delegate) after the CBCell has been created.

for more information about delegates look in the apple documentation here:
http://developer.apple.com/documentation...gates.html

---Kelvin--
15.4" MacBook Pro revA
1.83GHz/2GB/250GB
Quote this message in a reply
Post Reply