Difference between revisions of "Config Files (简体中文)"

(love.conf)
(love.conf)
Line 27: Line 27:
 
在发行游戏时,把不需要的模块设置为false是一件值得鼓励的事。这将减少启动时间(稍微的)和减少内存占用(稍微的)。
 
在发行游戏时,把不需要的模块设置为false是一件值得鼓励的事。这将减少启动时间(稍微的)和减少内存占用(稍微的)。
  
下面是0.92版本的所有选项及它们的缺省值列表:
+
下面是'''0.92'''版本的所有选项及它们的缺省值列表:
 
<source lang="lua">  
 
<source lang="lua">  
 
function love.conf(t)
 
function love.conf(t)
     t.title = "Untitled"        -- 运行游戏窗口的标题 (string)
+
     t.identity = nil                  -- 盘存文件夹的名称 (string)
     t.author = "Unnamed"        -- 游戏作者 (string)
+
     t.version = 0                      -- 此游戏对应的 LÖVE 版本(number)
     t.identity = nil           -- 盘存文件夹的名称 (string)
+
    t.console = false                  -- 附带控制台 (boolean, Windows only)
     t.version = 0               -- 此游戏对应的 LÖVE 版本(number)
+
 
     t.console = false           -- 附带控制台 (boolean, Windows only)
+
    t.window.title = "Untitled"        -- 程序窗口标题 (string)
     t.screen.width = 800        -- 窗口宽 (number)
+
     t.window.icon = nil               -- 使用一张游戏目录中的图片作为窗口图标 (string)
     t.screen.height = 600      -- 窗口高 (number)
+
     t.window.width = 800               -- 程序窗口宽 (number)
     t.screen.fullscreen = false -- 开启全屏 (boolean)
+
    t.window.height = 600              -- 程序窗口高 (number)
     t.screen.vsync = true       -- 开启垂直同步 (boolean)
+
     t.window.borderless = false        -- 移除所有程序边框的视觉效果 (boolean)
     t.screen.fsaa = 0          -- FSAA-buffers 大小 (number)
+
    t.window.resizable = false         -- 允许鼠标拖动调整窗口的宽度和高度 (boolean)
     t.modules.joystick = true   -- 开启手柄模块 (boolean)
+
     t.window.minwidth = 1              -- 程序窗口的最小宽度,仅当t.window.resizable = true 时生效 (number)
     t.modules.audio = true     -- 开启音频模块 (boolean)
+
     t.window.minheight = 1            -- 程序窗口的最小高度,仅当t.window.resizable = true 时生效 (number)
     t.modules.keyboard = true   -- 开启键盘模块 (boolean)
+
     t.window.fullscreen = false       -- 打开程序后全屏运行游戏 (boolean)
     t.modules.event = true     -- 开启事件模块 (boolean)
+
     t.window.fullscreentype = "normal" -- 标准全屏或者桌面全屏 (string)
     t.modules.image = true     -- 开启图像模块 (boolean)
+
    t.window.vsync = true             -- 垂直同步 (boolean)
     t.modules.graphics = true   -- 开启图形模块 (boolean)
+
     t.window.fsaa = 0                 -- 采用多样本采样抗锯齿 (number)
     t.modules.timer = true     -- 开启定时器模块 (boolean)
+
    t.window.display = 1              -- 显示器的指示显示窗口 (number)
     t.modules.mouse = true      -- 开启鼠标模块 (boolean)
+
    t.window.highdpi = false           -- 允许在视网膜显示器(Retina)下使用高DPI模式 (boolean)
     t.modules.sound = true     -- 开启声音模块 (boolean)
+
    t.window.srgb = false              -- 在屏幕上显示时允许使用sRGB伽马校正 (boolean)
     t.modules.physics = true   -- 开启物理模块 (boolean)
+
 +
     t.modules.audio = true             -- 加载 audio        模块 (boolean)
 +
     t.modules.event = true             -- 加载 event        模块 (boolean)
 +
     t.modules.graphics = true         -- 加载 graphics    模块 (boolean)
 +
     t.modules.image = true             -- 加载 image        模块 (boolean)
 +
     t.modules.joystick = true         -- 加载 the joystick 模块 (boolean)
 +
     t.modules.keyboard = true         -- 加载 keyboard    模块 (boolean)
 +
     t.modules.math = true             -- 加载 math        模块 (boolean)
 +
     t.modules.mouse = true             -- 加载 mouse        模块 (boolean)
 +
    t.modules.physics = true          -- 加载 physics     模块 (boolean)
 +
    t.modules.sound = true            -- 加载 sound        模块 (boolean)
 +
    t.modules.system = true            -- 加载 system      模块 (boolean)
 +
    t.modules.timer = true            -- 加载 timer        模块 (boolean)
 +
     t.modules.window = true           -- 加载 window      模块 (boolean)
 +
     t.modules.thread = true           -- 加载 thread      模块 (boolean)
 
end
 
end
 
</source>
 
</source>
Line 55: Line 69:
 
注意,不能禁止[[love.filesystem]]; 他是被强制使用的。同样对 [[love]] 模块本身也是如此。
 
注意,不能禁止[[love.filesystem]]; 他是被强制使用的。同样对 [[love]] 模块本身也是如此。
  
请注意,最新版本的<code>love.conf</code>函数的选项内容总是可能会发生变化的,请注意这一点,0.91及更早版本的<code>love.conf</code>配置列表请参看[http://love2d.org/wiki/Config_Files#love.conf 英文wiki]
+
最新版本的<code>love.conf</code>函数的选项内容总是可能会发生变化的,请注意这一点,'''0.91'''及更早版本的<code>love.conf</code>配置列表请参看[http://love2d.org/wiki/Config_Files#love.conf 英文wiki]
  
 
== Other Languages ==
 
== Other Languages ==

Revision as of 10:29, 17 September 2015

介绍

如果在游戏文件夹中(或在 .love 文件中)有一个名为 conf.lua 的文件, 它将在 LÖVE 模块加载 之前 运行。你能使用这个文件重写稍后将被 LÖVE '启动' 脚本调用的 love.conf 函数。利用 love.conf 函数, 可以设置一些配置选项和改变一些设置,诸如窗口默认尺寸,要加载哪些模块及其它的一些设置。

love.conf

love.conf 函数有一个参数:一个填满所有默认数值的表,并且你可以根据喜好更改这些参数。例如,想更改默认的屏幕尺寸:

function love.conf(t)
    t.window.width = 1024
    t.window.height = 768
    --[[ 0.8及之前版本为:
    t.screen.width = 1024
    t.screen.height = 768
    ]]
end

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

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

在发行游戏时,把不需要的模块设置为false是一件值得鼓励的事。这将减少启动时间(稍微的)和减少内存占用(稍微的)。

下面是0.92版本的所有选项及它们的缺省值列表:

 
function love.conf(t)
    t.identity = nil                   -- 盘存文件夹的名称 (string)
    t.version = 0                      -- 此游戏对应的 LÖVE 版本(number)
    t.console = false                  -- 附带控制台 (boolean, Windows only)

    t.window.title = "Untitled"        -- 程序窗口标题 (string)
    t.window.icon = nil                -- 使用一张游戏目录中的图片作为窗口图标 (string)
    t.window.width = 800               -- 程序窗口宽 (number)
    t.window.height = 600              -- 程序窗口高 (number)
    t.window.borderless = false        -- 移除所有程序边框的视觉效果 (boolean)
    t.window.resizable = false         -- 允许鼠标拖动调整窗口的宽度和高度 (boolean)
    t.window.minwidth = 1              -- 程序窗口的最小宽度,仅当t.window.resizable = true 时生效 (number)
    t.window.minheight = 1             -- 程序窗口的最小高度,仅当t.window.resizable = true 时生效 (number)
    t.window.fullscreen = false        -- 打开程序后全屏运行游戏 (boolean)
    t.window.fullscreentype = "normal" -- 标准全屏或者桌面全屏 (string)
    t.window.vsync = true              -- 垂直同步 (boolean)
    t.window.fsaa = 0                  -- 采用多样本采样抗锯齿 (number)
    t.window.display = 1               -- 显示器的指示显示窗口 (number)
    t.window.highdpi = false           -- 允许在视网膜显示器(Retina)下使用高DPI模式 (boolean)
    t.window.srgb = false              -- 在屏幕上显示时允许使用sRGB伽马校正 (boolean)
 
    t.modules.audio = true             -- 加载 audio        模块 (boolean)
    t.modules.event = true             -- 加载 event        模块 (boolean)
    t.modules.graphics = true          -- 加载 graphics     模块 (boolean)
    t.modules.image = true             -- 加载 image        模块 (boolean)
    t.modules.joystick = true          -- 加载 the joystick 模块 (boolean)
    t.modules.keyboard = true          -- 加载 keyboard     模块 (boolean)
    t.modules.math = true              -- 加载 math         模块 (boolean)
    t.modules.mouse = true             -- 加载 mouse        模块 (boolean)
    t.modules.physics = true           -- 加载 physics      模块 (boolean)
    t.modules.sound = true             -- 加载 sound        模块 (boolean)
    t.modules.system = true            -- 加载 system       模块 (boolean)
    t.modules.timer = true             -- 加载 timer        模块 (boolean)
    t.modules.window = true            -- 加载 window       模块 (boolean)
    t.modules.thread = true            -- 加载 thread       模块 (boolean)
end

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

最新版本的love.conf函数的选项内容总是可能会发生变化的,请注意这一点,0.91及更早版本的love.conf配置列表请参看英文wiki

Other Languages