Game Development Reference
Kobold2D takes care of the entire app start-up process for you and hides it within the
KKAppDelegate class from which the AppDelegate class inherits. In particular,
KKAppDelegate correctly sets up cocos2d based on the config.lua settings and
encapsulates platform-specific app delegate code. This allows Kobold2D to integrate
changes to the app delegate class introduced by newer cocos2d versions and makes
them available to your projects.
The KKAppDelegate class is a regular UIApplicationDelegate on iOS and
an NSApplicationDelegate class on Mac OS; you can implement (override) any
of the app delegate protocol methods yourself whenever you need to do so. However,
you should make sure to call the super implementation of overridden methods to ensure
that KKAppDelegate still performs its duties.
The only custom method that you may find useful is initializationComplete ,
which is called after the app and cocos2d have been fully initialized but before the first
scene is about to be run. You can call the CCDirector runWithScene method in-
side initializationComplete to run a specific scene. However, that's not re-
quired, because the config.lua file has a setting FirstSceneClassName that
lets you specify just the name of the class that cocos2d should run as its first scene
without writing any code.
In essence, the Kobold2D classes KKMain and KKAppDelegate provide the com-
mon functionality developers expect from these classes. Furthermore, they provide the
foundation code for any Kobold2D project, enabling you to use Lua for configuration
files, among other things. You also have less code to maintain. In particular, if there's
an essential change to these classes in iOS, Mac OS, or cocos2d, Kobold2D will take
care of these changes or additions for you.
The Start-up Configuration File
Kobold2D always loads the Lua script file config.lua , which is in the Re-
sources group of each Kobold2D project.
The config.lua script file returns a Lua table containing all the game's settings. A
Lua table is a flexible data structure that combines the features of dictionaries (indexed
by string) and arrays (indexed by value). You can create deeply nested Lua
tables—which in terms of possibilities equal XML files or property lists, but with a rel-
atively simple, readable syntax with built-in error-reporting.