Use reify instead of proxy, add input function, and add global interop macros
This commit is contained in:
@@ -34,8 +34,29 @@
|
||||
:y (.getY (Gdx/input))
|
||||
nil))
|
||||
|
||||
(defmacro input-key
|
||||
[key]
|
||||
`~(symbol
|
||||
(str utils/gdx-package ".Input$Keys/" (utils/key->static-field key))))
|
||||
|
||||
(defmacro is-pressed?
|
||||
[key]
|
||||
`(.isKeyPressed (Gdx/input)
|
||||
~(symbol (str utils/gdx-package ".Input$Keys/"
|
||||
(utils/key->static-field key)))))
|
||||
`(.isKeyPressed (Gdx/input) (input-key ~key)))
|
||||
|
||||
(defn input
|
||||
[& {:keys [key-down key-typed key-up mouse-moved
|
||||
scrolled touch-down touch-dragged touch-up]
|
||||
:or {key-down dummy key-typed dummy key-up dummy mouse-moved dummy
|
||||
scrolled dummy touch-down dummy touch-dragged dummy touch-up dummy}}]
|
||||
(reify InputProcessor
|
||||
(keyDown [this keycode] (key-down keycode))
|
||||
(keyTyped [this character] (key-typed character))
|
||||
(keyUp [this keycode] (key-up keycode))
|
||||
(mouseMoved [this screen-x screen-y] (mouse-moved screen-x screen-y))
|
||||
(scrolled [this amount] (scrolled amount))
|
||||
(touchDown [this screen-x screen-y pointer button]
|
||||
(touch-down screen-x screen-y pointer button))
|
||||
(touchDragged [this screen-x screen-y pointer]
|
||||
(touch-dragged screen-x screen-y pointer))
|
||||
(touchUp [this screen-x screen-y pointer button]
|
||||
(touch-up screen-x screen-y pointer button))))
|
||||
|
||||
Reference in New Issue
Block a user