|
|
-
- require("gameinput.KeyInput")
- require("gameinput.MouseInput")
- require("gameinput.GestureConfig")
-
-
-
- GameInputManager = GameInputManager or BaseClass()
- local GameInputManager = GameInputManager
- local os = os
- GameInputManager.GameInputEvent = {
- MOUSE_PRESS = "MOUSE_PRESS",
- MOUSE_MOVE = "MOUSE_MOVE",
- MOUSE_RELEASE = "MOUSE_RELEASE",
- }
-
- function GameInputManager:__init()
- GameInputManager.Instance = self
-
- self.key_input = KeyInput.New()
-
- self.mouse_input = MouseInput.New()
-
-
- Runner.Instance:AddRunObj(self)
- self.update_interval = 0.3
- self.last_update = os.clock()
- self.is_update_interval = false
- end
-
- function GameInputManager:Update()
- if not self.is_update_interval and os.clock() - self.last_update < self.update_interval then
- return
- end
- self.is_update_interval = true
-
- KeyInput.Update(self.key_input)
-
- if self.mouse_input then
- MouseInput.Update(self.mouse_input)
- end
- end
-
- function GameInputManager:GetKeyInput()
- return self.key_input
- end
-
- function GameInputManager:GetMouseInput()
- return self.mouse_input
- end
-
- function GameInputManager:__delete()
- self.key_input:DeleteMe()
-
- if self.mouse_input then
- self.mouse_input:DeleteMe()
- end
- end
|