I am new to game development but I need to know if it is possible to create a save game feature in love2d with lua.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Sure. You can use a variety of libraries available. My current recommendation is Ser Binser (Ser has been deprecated). This process is called "table serialization." Then, you can do something like this to effectively create a "save."
local ser = require 'Path.to.ser'
local save
function love.load()
if love.filesystem.exists( 'Save.lua' ) then
save = love.filesystem.load( 'Save.lua' )
else
save = {} -- Put settings in here.
end
end
-- etc. etc.
function love.quit()
love.filesystem.write( 'Save.lua', save )
end