2

シンプルなテキストがあり、テキストをクリックすると終了します。申し訳ありませんが、love2dは初めてです

quit = love.graphics.print( "Quit", 450,375)

function love.mousepressed(quit)
  love.event.quit()
end
4

2 に答える 2

1

を使用する代わりに、 Textオブジェクトを作成することをお勧めしますlove.graphics.print。次に、チェックでその高さlove.graphics.drawを照会し、 を使用して表示できます。コードは次のようになります。

function love.draw ()
  love.graphics.draw(quit.text, quit.x, quit.y)
end

function love.load ()
  local font = love.graphics.getFont()
  quit = {}
  quit.text = love.graphics.newText(font, "Quit")
  quit.x = 450
  quit.y = 375
end

function love.mousepressed (x, y, button, istouch)
  if x >= quit.x and x <= quit.x + quit.text:getWidth() and
     y >= quit.y and y <= quit.y + quit.text:getHeight() then
    love.event.quit()
  end
end
于 2016-11-24T19:38:31.463 に答える
1
function love.update(dt)
    function love.mousepressed( x, y)   
        if x > 440 and x < 540 and y > 380 and y < 410 then 
            love.event.quit()
        end
    end
end
于 2014-02-27T16:07:52.833 に答える