Page 1 of 1

How to close the window? [SOLVED]

Posted: Sun Jul 20, 2014 4:50 pm
by Lolocks
From my previous help posts, I think most of you know that I'm relatively new to love2d.

Anyways, I'm trying to make it so when you hit the >esc< button on your keyboard, the game will close. I've looked around the wiki and didn't find anything (or maybe i'm bad at looking for things).

Here's the code I want it to work it:

Code: Select all

if love.keyboard.isDown("escape") then
	--exit the game
end

Re: How to close the window?

Posted: Sun Jul 20, 2014 5:00 pm
by undef
The function you're looking for is called love.event.quit.
It's always ok to ask for help, but I really recommend browsing through the entire wiki, then you know best what the framework is capable of.

Re: How to close the window?

Posted: Sun Jul 20, 2014 5:03 pm
by Highjhacker
Hey, in the function love.keypressed :

Code: Select all

function love.keypressed(key, unicode)
	if key == "escape" then
		love.event.quit()
	end
end
http://love2d.org/wiki/love.event.quit

Re: How to close the window? [SOLVED]

Posted: Sun Jul 20, 2014 5:07 pm
by Lolocks
Thanks!

Man, I can't believe I forgot to check the events. Lol.