(本文使用Windows平台)
1、游戏配置文件 conf.lua
Love2D 用 conf.lua 文件来加载游戏中重要的配置,它在 Love 模块之前加载。
love.conf 函数用于重写配置,它接受一个存储游戏默认配置值的table作为参数,通过操作此table来修改我们需要的配置。
如果想改变默认的窗口尺寸,可以这样写:
If you want to change the default window size, for instance, do:
function love.conf(t) t.window.width = 1024 -- t.screen.width in 0.8.0 and earlier t.window.height = 768 -- t.screen.height in 0.8.0 and earlier end
如果不想加载物理模块或手柄模块,可以这样设置:
If you don‘t need the physics module or joystick module, do the following.
function love.conf(t) t.modules.joystick = false t.modules.physics = false end
将一些无用的模块设置为false有助于释放内存,让游戏运行更流畅。但是需要注意的是,love和love.filesytem模块是不可以禁止的,而love.graphics需要love.window的支持。
Setting unused modules to false is encouraged when you release your game. It reduces startup time slightly (especially if the joystick module is disabled) and reduces memory usage (slightly).
Note that you can‘t disable love.filesystem; it‘s mandatory. The same goes for the love module itself. love.graphics needs love.window to be enabled.
2、conf 选项列表
Here is a full list of options and their default values for LÖVE 0.9.2:
function love.conf(t) t.identity = nil -- The name of the save directory (string) t.version = "0.9.2" -- The LÖVE version this game was made for (string) t.console = false -- Attach a console (boolean, Windows only) t.window.title = "Untitled" -- The window title (string) t.window.icon = nil -- Filepath to an image to use as the window‘s icon (string) t.window.width = 800 -- The window width (number) t.window.height = 600 -- The window height (number) t.window.borderless = false -- Remove all border visuals from the window (boolean) t.window.resizable = false -- Let the window be user-resizable (boolean) t.window.minwidth = 1 -- Minimum window width if the window is resizable (number) t.window.minheight = 1 -- Minimum window height if the window is resizable (number) t.window.fullscreen = false -- Enable fullscreen (boolean) t.window.fullscreentype = "normal" -- Standard fullscreen or desktop fullscreen mode (string) t.window.vsync = true -- Enable vertical sync (boolean) t.window.fsaa = 0 -- The number of samples to use with multi-sampled antialiasing (number) t.window.display = 1 -- Index of the monitor to show the window in (number) t.window.highdpi = false -- Enable high-dpi mode for the window on a Retina display (boolean) t.window.srgb = false -- Enable sRGB gamma correction when drawing to the screen (boolean) t.window.x = nil -- The x-coordinate of the window‘s position in the specified display (number) t.window.y = nil -- The y-coordinate of the window‘s position in the specified display (number) t.modules.audio = true -- Enable the audio module (boolean) t.modules.event = true -- Enable the event module (boolean) t.modules.graphics = true -- Enable the graphics module (boolean) t.modules.image = true -- Enable the image module (boolean) t.modules.joystick = true -- Enable the joystick module (boolean) t.modules.keyboard = true -- Enable the keyboard module (boolean) t.modules.math = true -- Enable the math module (boolean) t.modules.mouse = true -- Enable the mouse module (boolean) t.modules.physics = true -- Enable the physics module (boolean) t.modules.sound = true -- Enable the sound module (boolean) t.modules.system = true -- Enable the system module (boolean) t.modules.timer = true -- Enable the timer module (boolean) t.modules.window = true -- Enable the window module (boolean) t.modules.thread = true -- Enable the thread module (boolean) end