我打印的文字说“是”。我必须按箭头的形状按钮。我试图得到它,如果我点击左箭头它说“不”,如果我点击右箭头说“是”。
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
答案 0 :(得分:1)
如下:
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
!