0

我打印了“是”的文字。我必须按箭头形状的按钮。我试图得到它,这样如果我点击左箭头,它会说“否”,如果我点击右箭头,就会说“是”。

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
4

1 回答 1

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游戏的每一帧!

于 2014-02-28T12:50:43.513 回答