Page 1 of 1
love.event freezing system
Posted: Tue May 08, 2012 10:02 pm
by saiko-chriskun
Code: Select all
function love.draw()
for event, key in love.event.poll() do
if event == 'keypressed' then
love.graphics.print(key, 0, 0)
end
end
end
function love.keypressed(key, unicode)
love.event.push('keypressed', key)
end
The above causes love to freeze once a key is hit. any help?
Re: love.event freezing system
Posted: Wed May 09, 2012 12:09 am
by Jasoco
You're not supposed to call event yourself. That's done for you in love.run() which is a function you can't see, but it's there, and it makes sure everything works.
Look into love.keyboard.isDown() instead.
Re: love.event freezing system
Posted: Wed May 09, 2012 6:28 am
by bartbes
Or just setting a variable.
Now, as to why it's freezing:
love.keypressed is executed in love.run's event loop, whenever the 'keypressed' event has been sent, your love.keypressed sends a new 'keypressed', so it keeps on handling these new events and therefore it creates in infinite loop.