core: add a way to get keyboard callbacks from current scene
This commit is contained in:
parent
1aef8ad49d
commit
324a5854b7
4 changed files with 43 additions and 2 deletions
|
@ -36,3 +36,11 @@ end
|
||||||
function love.mousepressed( x, y, button, istouch )
|
function love.mousepressed( x, y, button, istouch )
|
||||||
core:mousepressed(x, y, button, istouch)
|
core:mousepressed(x, y, button, istouch)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function love.keypressed( key, scancode, isrepeat )
|
||||||
|
core:keypressed( key, scancode, isrepeat )
|
||||||
|
end
|
||||||
|
|
||||||
|
function love.keyreleased(key)
|
||||||
|
core:keyreleased( key )
|
||||||
|
end
|
||||||
|
|
|
@ -57,7 +57,7 @@ function CoreSystem:new()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- MOUSE FUNCTIONS
|
-- MOUSE FUNCTIONS
|
||||||
-- Initialize and configure the core object
|
-- get directly the mouse when needed
|
||||||
|
|
||||||
function CoreSystem:mousemoved(x, y, dx, dy)
|
function CoreSystem:mousemoved(x, y, dx, dy)
|
||||||
local x, y = self.screen:project(x, y)
|
local x, y = self.screen:project(x, y)
|
||||||
|
@ -70,6 +70,17 @@ function CoreSystem:mousepressed( x, y, button, istouch )
|
||||||
self.scenemanager:mousepressed( x, y, button, istouch )
|
self.scenemanager:mousepressed( x, y, button, istouch )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- KEYBOARD FUNCTIONS
|
||||||
|
-- get directly the keyboard when needed
|
||||||
|
|
||||||
|
function CoreSystem:keypressed( key, scancode, isrepeat )
|
||||||
|
self.scenemanager:keypressed( key, scancode, isrepeat )
|
||||||
|
end
|
||||||
|
|
||||||
|
function CoreSystem:keyreleased( key )
|
||||||
|
self.scenemanager:keyreleased( key )
|
||||||
|
end
|
||||||
|
|
||||||
-- UPDATE FUNCTIONS
|
-- UPDATE FUNCTIONS
|
||||||
-- Load every sytem every update functions of the scene and objects
|
-- Load every sytem every update functions of the scene and objects
|
||||||
|
|
||||||
|
|
|
@ -72,6 +72,17 @@ function Scene:mousepressed( x, y, button, istouch )
|
||||||
-- Empty function, is just here to avoid crash
|
-- Empty function, is just here to avoid crash
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- KEYBOARD FUNCTIONS
|
||||||
|
-- Add send keys functions to the scene
|
||||||
|
|
||||||
|
function SceneManager:keypressed( key, scancode, isrepeat )
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
function SceneManager:keyreleased( key )
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
-- DRAW FUNCTIONS
|
-- DRAW FUNCTIONS
|
||||||
-- Draw the scene and its content
|
-- Draw the scene and its content
|
||||||
|
|
||||||
|
@ -79,7 +90,7 @@ function Scene:draw()
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- KEYBOARD FUNCTIONS
|
-- INPUT FUNCTIONS
|
||||||
-- Handle inputs from keyboard/controllers
|
-- Handle inputs from keyboard/controllers
|
||||||
|
|
||||||
function Scene:setKeys()
|
function Scene:setKeys()
|
||||||
|
|
|
@ -90,6 +90,17 @@ function SceneManager:mousepressed( x, y, button, istouch )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- KEYBOARD FUNCTIONS
|
||||||
|
-- Add send keys functions to the scene
|
||||||
|
|
||||||
|
function SceneManager:keypressed( key, scancode, isrepeat )
|
||||||
|
self.currentScene:keypressed( key, scancode, isrepeat )
|
||||||
|
end
|
||||||
|
|
||||||
|
function SceneManager:keyreleased( key )
|
||||||
|
self.currentScene:keyreleased( key )
|
||||||
|
end
|
||||||
|
|
||||||
-- DRAW FUNCTIONS
|
-- DRAW FUNCTIONS
|
||||||
-- Draw the current scene
|
-- Draw the current scene
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue