Disable Input when Sleeping

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
piano_wizz
Prole
Posts: 2
Joined: Sat Feb 12, 2011 3:00 pm

Disable Input when Sleeping

Post by piano_wizz »

Good afternoon, I am trying to throttle input for a set amount of time, in short the application will play a sound, and display some images each time a key is pressed but I want to throttle this so that there is a pause. (IE the audio has time to finish)

I'm using love.timer.sleep(1000) but finding that it will pause and then will act like any key pressed in that 1 second sleep is pressed each second after the sleep has ended. I want to know if there is a way to disable input while sleep is active so that key presses in that time are not registered.

Thanks in advance, Dan.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Disable Input when Sleeping

Post by bartbes »

love.timer.sleep is horrible, it stops code execution, and so effectively hangs your game. You should check whether it's ready wherever you check for keypresses. In your case you probably want to do something like

Code: Select all

if source:isStopped() then
    doEpicThings()
end
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 4 guests