Posted 15 July 2015 - 08:14 PM
Hello together.
I'm tying to implement a class with seperate render- and update cycle. Both cycles should run at the same time.
My approach was the parralel API using
I used a frame counter which displays at the bottom of the screen to check if the rendering takes place.
The update cycle which processes the data changes and the keyboard input, however, doesn't work as expected. Basically the update cycle looks like this:
function itself. This shouldn't be an issue.
The Problem is, that the application doesn't respond to my key events. Any idea why not?
I appreciate any help…
I've read something about blocking in the Wiki. But since I run both cycles with the parallel API this should work, right? I mean.. that's what the API is for, isn't it? Running one task independently while another thread sleeps or waits?
I'm tying to implement a class with seperate render- and update cycle. Both cycles should run at the same time.
My approach was the parralel API using
parallel.waitForAny(Update(), Render())
This seems to work fine for the render cycle which will only output data to the screen. I can confirm that the render cycle is running.I used a frame counter which displays at the bottom of the screen to check if the rendering takes place.
The update cycle which processes the data changes and the keyboard input, however, doesn't work as expected. Basically the update cycle looks like this:
function Update()
while true do
local event, key = os.pullEvent("key");
if key == keys.down then
object:setSelectedItem(object:getSelectedItem() + 1)
end
if key == keys.up then
object:setSelectedItem(object:getSelectedItem() - 1)
end
if key == keys.enter then
break
end
end
end
The limits for the selection are handled by the setSelectedItem() function itself. This shouldn't be an issue.
The Problem is, that the application doesn't respond to my key events. Any idea why not?
I appreciate any help…
I've read something about blocking in the Wiki. But since I run both cycles with the parallel API this should work, right? I mean.. that's what the API is for, isn't it? Running one task independently while another thread sleeps or waits?
Edited on 15 July 2015 - 06:24 PM