2014-02-27 53 views
0

我打印了显示“是”的文本。我必须按箭头的形状。我试图弄明白,如果我点击左边的箭头说“不”,如果我点击右边的箭头说“是”。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 
+0

'x> 424和x <335'。选择一个'x'。它会满足这两个条件吗? – hjpotter92

+0

对不起。它的意思是435.原始文章已被编辑 – Ross

回答

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