Extrait du cours et tutoriel Lua Config.lua Parameters
What is config.lua ?
The file config.lua is used to store all game configuration data. The primary purpose is to make the startup process of your iOS app data-driven.
Most pre-existing parameters are for the configuration of Cocos2D global settings and described below. But you can also use it to supply your code with your own startup parameters.
The syntax of the file is as follows:
local config =
— Kobold2D startup parameters go here
— your parameters go here, example:
DebugMode = YES
KKStartupConfig Parameters Explained
DirectorType & DirectorTypeFallback
Orientation & Autorotation
ShouldAutorotateToLandscapeOrientations & ShouldAutorotateToPortraitOrientations
LoadOnlyPortraitBanners & LoadOnlyLandscapeBanners
Mac OS X exclusive settings
« ClassName »
FirstSceneClassName = « GameScene »;
« ClassName » is a string that defines the name of an Objective-C class which is the first scene that should be loaded. This class must be derived from a CCScene class.
If an Objective-C class with this name can not be found, Kobold2D looks for a lua file in the format ClassName.lua (beware: filenames are case-sensitive on iOS!). If found, it will load this script and create a KKScriptScene derived class which will become the first scene.
If neither is found or the FirstSceneClassName is an empty string, it is up to you to write code that calls the CCDirector runWithScene method.
You normally do this in the AppDelegate class, by providing the following function and code:
[[CCDirector sharedDirector] runWithScene:[MyScene node]];
DirectorType & DirectorTypeFallback
DirectorType determines how Cocos2D’s Director implements the game loop.
DirectorTypeFallback allows you to specify to which Director type Cocos2D should fall back to in case the primary Director type is unavailable.
This is only needed if you specify the DisplayLink director because it requires iOS 3.1 or higher and may not be available on all devices.
The default setting is the DisplayLink director, which couples the updates with the screen refresh rate using a object. CADisplayLink If you want to use UIKit views in your game, it is highly recommended to use the ThreadMainLoop director, which runs Cocos2D on a seperate thread except for the rendering part. This will make UIKit views more responsive while Cocos2D is running.
The MainLoop director uses a classic « while (isRunning) » endless loop which is non-cooperative and should be avoided since it may not interact well with iOS multitasking. The NSTimer is a safe fallback but has since become largely irrelevant, since almost all devices have iOS 3.1 installed and can run the DisplayLink director. But it is still used as the safe fallback option.
Set to YES to display a framerate counter in the lower left corner of the screen. By the default, the framerate counter is only visible in Debug and Release builds, but will be disabled automatically in Ad Hoc and App Store distribution builds.
In some cases, you want the users of your Ad Hoc builds to also see the framerate. Set DisplayFPSInAdHocBuilds to YES if you want to show the framerate in Ad Hoc builds as well. DisplayFPS must also be set to YES. And the framerate counter will still be disabled in App Store distribution builds.
This must be enabled to receive any events from the user. This includes touch events as well as keyboard input events. Typically you’ll want this to be enabled.
Si le lien ne fonctionne pas correctement, veuillez nous contacter (mentionner le lien dans votre message)
Cours et tutoriel Lua Config.lua Parameters (174 KO) (Cours PDF)