Skip to content
This repository has been archived by the owner on Mar 11, 2019. It is now read-only.
This repository has been archived by the owner on Mar 11, 2019. It is now read-only.

key-pressed? macro #35

Closed
Chuckler opened this issue Jun 16, 2014 · 1 comment
Closed

key-pressed? macro #35

Chuckler opened this issue Jun 16, 2014 · 1 comment

Comments

@Chuckler
Copy link

Hi,
i am asking myself, why is 'key-pressed?' a macro? I'm not very familiar with clojure macro's and therefore i wasn't able to get code like this to run.

(key-pressed? (:my-key {:my-key :a} ) )

Is there a workaround?

@oakes
Copy link
Owner

oakes commented Jun 16, 2014

I made it a macro so it would create the appropriate static field at compile time instead of constantly at runtime. Here are function versions of key-code and key-pressed? you can use instead (you'll need to bring in the play-clj.utils namespace):

(defn key-code*
  [k]
  (eval (gdx-field "Input$Keys" (key->upper k))))

(defn key-pressed?*
  [k]
  (input! :is-key-pressed (key-code* k)))

@oakes oakes closed this as completed Jun 16, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants