CB Key handling
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.
Are you subclassing CBView? I am using an old version but that works for me.
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
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.
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.
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.![]()
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
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
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
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
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

