Game Development Reference
In-Depth Information
For example, the FirstSceneClassName setting lets you specify the name of a
class inheriting from CCScene or CCLayer (automatically wrapped inside a CCS-
cene ), which will be the first scene run by the CCDirector . You can enable iAd or
AdMob ad banners, or provide the default window position and size for Mac builds.
The big advantage of using a Lua-based configuration file is that the entire start-up
code is part of the Kobold2D code and can be updated in new versions if it needs to be.
As Kobold2D matures, more settings will be added to the start-up config, depending on
what developers need to change or include most in their apps. In addition, you can cre-
ate and use custom config.lua settings. The Hello World project provides an ex-
ample of loading custom settings. I'll get to that in the next section.
Tip You can learn more about Lua from the free Programming in Lua book,
available online on the official Lua home page at www.lua.org/pil . The
book is for an older version of Lua but is still largely relevant. You may also
want to browse the Lua reference manual at www.lua.org/manual to get a
quick overview of the language. Lua has grown to be the number-one scripting
language for game developers over the past ten years. It has a very small
memory footprint and speed-wise often comes close to 80 to 90 percent of the
performance achievable with C programming.
The Hello Kobold2D Scene and Layer
Let's move on to the actual scene class HelloWorldLayer , which is set as the first
scene via the config.lua setting FirstSceneClassName = "Hel-
loWorldLayer" . You'll notice that this first scene is actually derived from CCLay-
er . Kobold2D realizes that and automatically wraps the HelloWorldLayer class
into a CCScene instance behind the scenes.
Tip To avoid writing the repetitive +(id) scene method in each CCLayer
class, you can simply call the +(id) nodeWithScene method in Ko-
bold2D:
Search Nedrilad ::




Custom Search