How do I create a save game feature in love2d?

后端 未结 1 1598
花落未央
花落未央 2021-01-06 12:51

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条回答
  • 2021-01-06 13:10

    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
    
    0 讨论(0)
提交回复
热议问题