Config Files (简体中文)

介绍

如果在游戏文件夹中(或在 .love 文件中)有一个名为 conf.lua 的文件, 它将在 LÖVE 模块加载 之前 运行。你能使用这个文件重写稍后将被 LÖVE '启动' 脚本调用的 love.conf 函数。利用 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"        -- 运行游戏窗口的标题 (string)
    t.author = "Unnamed"        -- 游戏作者 (string)
    t.identity = nil            -- 盘存文件夹的名称 (string)
    t.version = 0               -- 此游戏对应的 LÖVE 版本(number)
    t.console = false           -- 附带控制台 (boolean, Windows only)
    t.screen.width = 800        -- 窗口宽 (number)
    t.screen.height = 600       -- 窗口高 (number)
    t.screen.fullscreen = false -- 开启全屏 (boolean)
    t.screen.vsync = true       -- 开启垂直同步 (boolean)
    t.screen.fsaa = 0           -- FSAA-buffers 大小 (number)
    t.modules.joystick = true   -- 开启手柄模块 (boolean)
    t.modules.audio = true      -- 开启音频模块 (boolean)
    t.modules.keyboard = true   -- 开启键盘模块 (boolean)
    t.modules.event = true      -- 开启事件模块 (boolean)
    t.modules.image = true      -- 开启图像模块 (boolean)
    t.modules.graphics = true   -- 开启图形模块 (boolean)
    t.modules.timer = true      -- 开启定时器模块 (boolean)
    t.modules.mouse = true      -- 开启鼠标模块 (boolean)
    t.modules.sound = true      -- 开启声音模块 (boolean)
    t.modules.physics = true    -- 开启物理模块 (boolean)
end

注意,不能禁止love.filesystem; 他是被强制使用的。同样对 love 模块本身也是如此。

Other Languages