Implemented love.mouse.getEvents() and mouse callbacks

This commit is contained in:
rxi
2016-09-24 10:58:02 +01:00
parent dd44e8d1a0
commit c8453c6f60
2 changed files with 47 additions and 2 deletions

View File

@@ -66,7 +66,16 @@ int main(void) {
"while true do\n"
/* Update mouse and handle mouse events */
"love.mouse.update()\n"
/* Keyboard Events*/
"for _, e in ipairs(love.mouse.getEvents()) do\n"
"if e.type == 'motion' then\n"
"if love.mousemoved then love.mousemoved(e.x, e.y, e.dx, e.dy) end\n"
"elseif e.type == 'pressed' then\n"
"if love.mousepressed then love.mousepressed(e.x, e.y, e.button) end\n"
"elseif e.type == 'released' then\n"
"if love.mousereleased then love.mousereleased(e.x, e.y, e.button) end\n"
"end\n"
"end\n"
/* Keyboard Events */
"for _, e in ipairs(love.keyboard.getEvents()) do\n"
"if e.type == 'down' then\n"
"if love.keypressed then love.keypressed(e.code) end\n"