love2d - 更新打印文本的文本



我打印了"是"的文本。 我必须按钮成箭头形状。我正在尝试获取它,以便如果我单击左箭头,它说"否",如果我单击右箭头则说"是"。

fsdefault = "Yes"
fs = love.graphics.print(fsdefault, 440, 160)
love.graphics.draw(larrow, 425, 163)
love.graphics.draw(rarrow, 470, 163)
function love.update(dt)
function love.mousepressed( x, y)
    if x > 424 and x < 435 and y > 161 and y < 172 then 
        fsdefault = "No"
    end
    if x > 275 and x < 320 and y > 305 and y < 325 then 
        fsdefault = "Yes"
    end
end
end

像这样的事情怎么样:

local fsdefault = ""
function love.mousepressed( x, y)
    if x > 424 and x < 435 and y > 161 and y < 172 then 
        fsdefault = "No"
    end
    if x > 275 and x < 320 and y > 305 and y < 325 then 
        fsdefault = "Yes"
    end
end
function love.draw()
    love.graphics.print(fsdefault, 440, 160)
    love.graphics.draw(larrow, 425, 163)
    love.graphics.draw(rarrow, 470, 163)
end

请注意,为清楚起见,您应该只在 love.draw 内执行屏幕绘制操作。

另外,尽量避免在 love.update 中声明函数。该代码片段将使爱重新定义love.mousepressed游戏的每一帧!

最新更新