Game Development Reference
In-Depth Information
The AppDelegate class in a Kobold2D project is a subclass of the KKAp-
pDelegate class provided by Kobold2D. Like the AppController class, it
subclasses NSObject and implements the UIApplicationDelegate pro-
tocol. KKAppDelegate does a lot of the work behind the scenes, leaving you to
deal with only three callback functions that you may want to use or not. For example,
the initializationComplete method is called by Kobold2D just before the
first scene is run. This is where you should add any code that needs to run before the
first scene is initialized. All the other settings you'd normally modify the source code
of the AppDelegate class for can be altered more conveniently in the con-
fig.lua file in Kobold2D projects.
To learn more about the AppDelegate 's various methods, what they do, and when
these messages are sent by the iOS SDK, you can look it up in Apple's reference docu-
mentation on the UIApplicationDelegate protocol at ht-
tp://developer.apple.com/iphone/library/documentation/
uikit/reference/UIApplicationDelegate_Protocol .
Note I'm talking about application startup, so I might as well talk about applic-
ation shutdown. You may eventually notice an oddity with the AppDeleg-
ate 's dealloc method. It never gets called! Any breakpoint set in the Ap-
pDelegate 's dealloc method will never be hit!
This is normal behavior. When iOS terminates an application, it simply wipes
the memory clean to speed up the shutdown process. That's why any code in-
side the dealloc method of the AppDelegate class is never run. As
it's very bad practice to call dealloc manually, this and calling [super
dealloc] is forbidden under ARC because ARC itself takes care of that
for you. If you ever need to run code in your AppDelegate just before the
application terminates, do it inside the applicationWillTermin-
ate method.
In a pure cocos2d project the most commonly changed lines of code in the Ap-
pDelegate class are:
[director_ setDisplayStats:YES];
[director_ setAnimationInterval:1.0/60];
Search Nedrilad ::




Custom Search