Config Files (简体中文)

介绍

如果有一个文件叫 conf.lua 在你的游戏目录下 (或者在 .love 文件里面), 他将被运行在LÖVE模块加载 之前。 你能使用这个文件重写love.conf 函数, 他将被调用被LÖVE'启动'脚本。使用 love.conf 函数, 你能使用一些配置选项,并且改变这些设置例如窗口的默认尺寸,这模块被加载,和其他的属性

love.conf

love.conf 函数带来一个参数:一个填满所有的默认数值的表,并且你根据需要更改这些参数。例如,如果你要更改默认的屏幕尺寸:

function love.conf(t)
    t.screen.width = 1024
    t.screen.height = 768
end

如果你不需要物理模块已经手柄模块,就这么写

function love.conf(t)
    t.modules.joystick = false
    t.modules.physics = false
end

设置不需要的模块为false是一件值得鼓励的事,尤其是你要发行你的游戏。他将缩减启动时间(稍微的)和内存占用(同样稍微的)。

这里是一个完整的选项列表和他们的默认值:

 
function love.conf(t)
    t.title = "Untitled"        -- The title of the window the game is in (string)
    t.author = "Unnamed"        -- The author of the game (string)
    t.identity = nil            -- The name of the save directory (string)
    t.version = 0               -- The LÖVE version this game was made for (number)
    t.console = false           -- Attach a console (boolean, Windows only)
    t.screen.width = 800        -- The window width (number)
    t.screen.height = 600       -- The window height (number)
    t.screen.fullscreen = false -- Enable fullscreen (boolean)
    t.screen.vsync = true       -- Enable vertical sync (boolean)
    t.screen.fsaa = 0           -- The number of FSAA-buffers (number)
    t.modules.joystick = true   -- Enable the joystick module (boolean)
    t.modules.audio = true      -- Enable the audio module (boolean)
    t.modules.keyboard = true   -- Enable the keyboard module (boolean)
    t.modules.event = true      -- Enable the event module (boolean)
    t.modules.image = true      -- Enable the image module (boolean)
    t.modules.graphics = true   -- Enable the graphics module (boolean)
    t.modules.timer = true      -- Enable the timer module (boolean)
    t.modules.mouse = true      -- Enable the mouse module (boolean)
    t.modules.sound = true      -- Enable the sound module (boolean)
    t.modules.physics = true    -- Enable the physics module (boolean)
end

注意你不能禁止love.filesystem; 他是被强制使用的。同样对 The same goes for the love module itself.

Other Languages