This repository has been archived by the owner. It is now read-only.

key-pressed? macro #35

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

Comments

2 participants
@Chuckler

Chuckler commented Jun 16, 2014

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

This comment has been minimized.

Show comment
Hide comment
@oakes

oakes Jun 16, 2014

Owner

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)))
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 Jun 16, 2014

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.