我正在尝试使用love2d在lua中设计这样一个表.当我阅读很多关于Lua的教程时,我无法创建这样的表,因为我不理解这个概念.任何人都可以帮我创建这个表吗?

我正在使用LOVE2D进行游戏,我差不多完成了.但是,我很担心; 即使安装了Love2d本身,用户也可以安装游戏吗?如果是这样,我该如何提取它?
我知道字母表中存在String.upper,但我正在寻找shift版本而不是字母版本,例如分号的"大写"将是冒号.当我尝试谷歌时,我得到了关于string.upper的无关结果.
我一直试图为用户创建一个框,一旦用户单击该框,就可以输入数据.这是我到目前为止,但单击该框不会导致文本输入添加到它.问题在哪里?
function love.load ()
txt1 = ""
columnx = { 50, 160, 260, 375, 495, 600, 710 }
columny = { 130, 230, 330, 440, 540, 640 }
if show1 == true then
function love.textinput(t)
txt1 = t
end
end
end
function love.mousepressed (x, y)
if
x >= columnx[4] and
x <= 435 and
y >= columny[1] and
y >= 145 then
show1 = true
end
end
function love.draw ()
love.graphics.print(txt1, columnx[4], columny[1])
end
Run Code Online (Sandbox Code Playgroud) 拜托,我在lua(love2d)中得到了代码:
nn = love.graphics.newImage'texture.png'
_1_1_cell = {
_2_2_grid = {
wall = {
texture = nn
}
}
}
function drawGrid( ... )
local rr, tt, oo, pp = 1, 1, 2, 2
local hh = '_'..rr..'_'..tt..'_cell._'..oo..'_'..pp..'_grid.wall.texture'
return
--this should draw texture at certain position
texture.quad( hh, {x,y}, {x,y}, {x,y}, {x,y} )
end
Run Code Online (Sandbox Code Playgroud)
问题是,它发送字符串而不是纹理数据。当打印hh时,它显示:_1_1_cell._2_2_grid.wall.texture,它是正确的,并且在代替hh直接使用时有效。所以问题是,如何转换字符串以使其加载我需要的东西?谢谢。
我正在使用anim8库,并引用了他对类似问题的回答,但我仍然不明白如何在按下按键行走/移动时触发我的动画:
-- main.lua
local anim8 = require('lib.anim8.anim8')
local player, animation, g
function love.load()
player = {}
player.spritesheet = love.graphics.newImage('sprites/hero.png')
player.x = 200
player.y = 200
player.speed = 50
g = anim8.newGrid(16, 24, player.spritesheet:getWidth(),
player.spritesheet:getHeight())
animation = anim8.newAnimation('loop', g('1-8,1-5'), 1.0)
end
function love.update(dt)
animation:update(dt)
if love.keyboard.isDown("w") then
animation = anim8.newAnimation('loop', g('4-6,1'), 0.1)
player.y = player.y - player.speed * dt
elseif love.keyboard.isDown("s") then
player.y = player.y + player.speed * dt
animation = anim8.newAnimation('loop', g('1-3,1'), 0.1)
elseif love.keyboard.isDown("a") and …Run Code Online (Sandbox Code Playgroud) background = love.graphics.newImage ("joust.png")
bird = love.graphics.newImage ("bird.png")
x = 0
y = 128
speed = 300
function love.update (dt)
if love.keyboard.isDown ("d") then
x = x + (speed * dt)
end
if love.keyboard.isDown ("a") then
x = x - (speed * dt)
end
if love.keyboard.isDown ("w") then
y = y - (speed * dt)
end
if love.keyboard.isDown ("s") then
y = y + (speed * dt)
end
end
function love.draw()
love.graphics.draw(bird, x, y)
for i = 0, love.graphics.getWidth() / …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用该luafun库love2d。然而Runninglua main.lua却love .抱怨缺少fun库。
我已经安装luafun了luarocks.
I wanna make a plugin where someone calls a function passes some info along with the call and makes a listenerfunction, the function has to look like this:
database.execute(database.Update)
:data({username="Jhon"})
:response(function(responseString, responseTable)
///
end)
Run Code Online (Sandbox Code Playgroud)
I know how to make a basic function call like this database.execute(_, _, _) but have no idea how to make it multi-line operation like this
database.execute()
:_()
:_()
Run Code Online (Sandbox Code Playgroud) 所以我得到了这段代码,由于某种原因,它给了我一个关于 LOVE 的空异常
function enemies_controller:spawnEnemy(x, y, rad)
enemy = {}
enemy.x = x
enemy.y = y
enemy.rad = rad
enemy.speedMulti = 1
table.insert(enemies_controller.enemies, enemy)
end
Run Code Online (Sandbox Code Playgroud)
函数像这样调用它:
enemies_controller.spawnEnemy(100, 100, 50)
Run Code Online (Sandbox Code Playgroud)
问题是,当我绘制时,敌人.rad 给了我一个空异常,因为敌人.x 接受第二个函数参数,敌人.y 接受第三个,并且没有一个接受第一个......所以我不确定什么正在发生