我正在使用lua创建一个项目,它会从lua中获取桌面上所有文件名的列表。但是,我无法弄清楚如何做到这一点,我也将使用love2d,因为它将成为一个游戏。你能告诉我怎么做吗?谢谢!
这是代码
function love.load()
require "player"
-- Lets add Some Variables!
-- Some Directory Suff first for Variables...
DesktopDirectory = love.filesystem.getUserDirectory().."Desktop"
DesktopFiles = love.filesystem.getDirectoryItems(DesktopDirectory)
-- These are the Images!
images = {
background = love.graphics.newImage("gfx/desktop.png")
}
players = {Player.New(50, 300, 40, 40, "gfx/stickman.png", true)}
love.graphics.setBackgroundColor(100, 220, 255)
for k in pairs(DesktopFiles) do
print(DesktopFiles[k])
end
end
function love.keypressed(k)
if k == "j" then
players[1].jump()
end
end
function love.update(dt)
for i in pairs(players) do
players[i].update()
end
end
function love.draw()
love.graphics.draw(images.background)
for i in pairs(players) do
players[i].draw()
end
end