core/scenes: improve input locking system
This commit is contained in:
parent
824fdbdf86
commit
793c05117a
2 changed files with 28 additions and 3 deletions
|
@ -36,6 +36,9 @@ function Scene:new()
|
|||
self.menusystem = MenuSystem()
|
||||
self.keys = core.input:getKeyList()
|
||||
|
||||
self.inputLocked = false
|
||||
self.inputLockedTimer = 0
|
||||
|
||||
self:register()
|
||||
end
|
||||
|
||||
|
@ -63,9 +66,33 @@ function Scene:clear()
|
|||
|
||||
end
|
||||
|
||||
function Scene:setKeys()
|
||||
if (self.inputLocked) then
|
||||
self.keys = core.input.fakekeys
|
||||
self.inputLockedTimer = self.inputLockedTimer - 1
|
||||
if (self.inputLockedTimer <= 0 ) then
|
||||
self.inputLockedTimer = false
|
||||
end
|
||||
else
|
||||
self.keys = core.input.keys
|
||||
end
|
||||
|
||||
self.menusystem.keys = self.keys
|
||||
end
|
||||
|
||||
function Scene:getKeys()
|
||||
if (self.inputLocked) then
|
||||
return self.keys
|
||||
else
|
||||
return core.input.fakekeys
|
||||
end
|
||||
end
|
||||
|
||||
function Scene:flushKeys()
|
||||
core.input:flushKeys()
|
||||
self.keys = core.input.keys
|
||||
self.inputLockedTimer = 1
|
||||
self.inputLocked = true
|
||||
end
|
||||
|
||||
return Scene
|
||||
|
|
|
@ -54,9 +54,7 @@ end
|
|||
|
||||
function SceneManager:update(dt)
|
||||
if (self.currentScene ~= nil) then
|
||||
local keys = self.controller.input.keys
|
||||
self.currentScene.keys = keys
|
||||
self.currentScene.menusystem.keys = keys
|
||||
self.currentScene:setKeys()
|
||||
self.currentScene.assets:update(dt)
|
||||
self.currentScene.menusystem:update(dt)
|
||||
self.currentScene:update(dt)
|
||||
|
|
Loading…
Reference in a new issue