Merge remote-tracking branch 'oakes/master'
This commit is contained in:
@@ -172,7 +172,8 @@ via the screen map.
|
||||
entities))
|
||||
|
||||
; input functions
|
||||
; Tip: convert :input-x and :input-y to screen coordinates with input->screen
|
||||
; Tip: convert :input-x and :input-y to screen coordinates with input->screen,
|
||||
; or just use (game :x) and (game :y) instead
|
||||
(defscreen my-screen
|
||||
; a key was pressed
|
||||
:on-key-down
|
||||
@@ -225,7 +226,6 @@ via the screen map.
|
||||
entities))
|
||||
|
||||
; gesture functions
|
||||
; Tip: use gesture-detector! to configure these functions
|
||||
(defscreen my-screen
|
||||
; the user dragged over the screen and lifted
|
||||
:on-fling
|
||||
@@ -322,21 +322,13 @@ via the screen map.
|
||||
entities))
|
||||
|
||||
; ui input functions (for play-clj.ui)
|
||||
; Tip: use click-listener! to configure these functions
|
||||
(defscreen my-screen
|
||||
; the ui entity was changed
|
||||
; the ui entity was clicked or changed
|
||||
:on-ui-changed
|
||||
(fn [screen entities]
|
||||
(println (:event screen)) ; the ChangeListener.ChangeEvent - http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/utils/ChangeListener.ChangeEvent.html
|
||||
(println (:actor screen)) ; the Actor - http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/Actor.html
|
||||
entities)
|
||||
; the ui entity was clicked
|
||||
:on-ui-clicked
|
||||
(fn [screen entities]
|
||||
(println (:event screen)) ; the InputEvent - http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/InputEvent.html
|
||||
(println (:input-x screen)) ; the x position of the finger/mouse
|
||||
(println (:input-y screen)) ; the y position of the finger/mouse
|
||||
entities)
|
||||
; the finger/mouse moved over the ui entity
|
||||
:on-ui-enter
|
||||
(fn [screen entities]
|
||||
@@ -383,7 +375,6 @@ via the screen map.
|
||||
entities))
|
||||
|
||||
; ui drag functions (for play-clj.ui)
|
||||
; Tip: use drag-listener! to configure these functions
|
||||
(defscreen my-screen
|
||||
:on-ui-drag
|
||||
(fn [screen entities]
|
||||
@@ -517,6 +508,10 @@ keywords and functions in pairs."
|
||||
|
||||
(set-screen! my-game main-screen text-screen)"
|
||||
[^Game game-object & screen-objects]
|
||||
(doseq [screen screen-objects]
|
||||
(assert (every? #(fn? (get screen %))
|
||||
[:show :render :hide :pause :resize :resume])
|
||||
"Attempted to set an invalid screen."))
|
||||
(let [run-fn! (fn [k & args]
|
||||
(doseq [screen screen-objects]
|
||||
(apply (get screen k) args)))]
|
||||
|
||||
@@ -101,10 +101,10 @@
|
||||
:fps (graphics! :get-frames-per-second)
|
||||
:fullscreen? (graphics! :is-fullscreen)
|
||||
:touched? (input! :is-touched)
|
||||
:x (throw (Exception. "Replace (game :x) with (input! :get-x)"))
|
||||
:y (throw (Exception. "Replace (game :y) with (input! :get-y)"))
|
||||
:point-x (input! :get-x (or arg 0))
|
||||
:point-y (- (graphics! :get-height) (input! :get-y (or arg 0)))
|
||||
:x (input! :get-x (or arg 0))
|
||||
:y (- (graphics! :get-height) (input! :get-y (or arg 0)))
|
||||
:point-x (game :x arg)
|
||||
:point-y (game :y arg)
|
||||
(u/throw-key-not-found k)))
|
||||
|
||||
(defmacro key-code
|
||||
@@ -153,7 +153,7 @@
|
||||
(audio! :new-sound (files! :internal path))))
|
||||
|
||||
(defmacro sound
|
||||
"Returns a [Sound](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/audio/Sound.html).
|
||||
"Returns a [Sound](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/audio/Sound.html). Supports wav, mp3, and ogg.
|
||||
|
||||
(sound \"playerhurt.wav\")
|
||||
(sound \"playerhurt.wav\" :play)"
|
||||
@@ -170,29 +170,25 @@
|
||||
`(let [^Sound object# ~object]
|
||||
(u/call! object# ~k ~@options)))
|
||||
|
||||
|
||||
(defn music*
|
||||
[path]
|
||||
(let [^FileHandle fh (if (string? path)
|
||||
(files! :internal path)
|
||||
path)]
|
||||
(or (u/load-asset (.path fh) Music)
|
||||
(audio! :new-music fh))))
|
||||
[^String path]
|
||||
(or (u/load-asset path Music)
|
||||
(audio! :new-music (files! :internal path))))
|
||||
|
||||
(defmacro music
|
||||
"Returns a [Sound](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/audio/Sound.html).
|
||||
"Returns a [Music](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/audio/Music.html). Supports wav, mp3, and ogg.
|
||||
|
||||
(sound \"playerhurt.wav\")
|
||||
(sound \"playerhurt.wav\" :play)"
|
||||
(music \"song.wav\")
|
||||
(music \"song.wav\" :play)"
|
||||
[path & options]
|
||||
`(let [^Music object# (music* ~path)]
|
||||
(u/calls! object# ~@options)))
|
||||
|
||||
(defmacro music!
|
||||
"Calls a single method on a `sound`.
|
||||
"Calls a single method on a `music`.
|
||||
|
||||
(sound! object :play)
|
||||
(sound! object :dispose)"
|
||||
(music! object :play)
|
||||
(music! object :dispose)"
|
||||
[object k & options]
|
||||
`(let [^Music object# ~object]
|
||||
(u/call! object# ~k ~@options)))
|
||||
|
||||
@@ -165,14 +165,13 @@ of the camera will be set."
|
||||
"Sets the position of `object`. If `object` is a screen, the position of the
|
||||
camera will be set."
|
||||
([object vec-3]
|
||||
(let [^Camera camera (u/get-obj object :camera)]
|
||||
(set! (. camera position) vec-3)))
|
||||
(position! object (x vec-3) (y vec-3) (z vec-3)))
|
||||
([object x-val y-val]
|
||||
(position! object x-val y-val nil))
|
||||
([object x-val y-val z-val]
|
||||
(when x-val (x! object x-val))
|
||||
(when y-val (y! object y-val))
|
||||
(when z-val (z! object z-val))))
|
||||
(some->> x-val (x! object))
|
||||
(some->> y-val (y! object))
|
||||
(some->> z-val (z! object))))
|
||||
|
||||
(defn direction
|
||||
"Returns the direction of the camera in `screen`."
|
||||
@@ -182,9 +181,24 @@ camera will be set."
|
||||
|
||||
(defn direction!
|
||||
"Sets the direction of the camera in `screen`."
|
||||
[screen x y z]
|
||||
[screen x-val y-val z-val]
|
||||
(let [^Camera camera (u/get-obj screen :camera)]
|
||||
(.lookAt camera x y z)
|
||||
(.lookAt camera x-val y-val z-val)
|
||||
(.update camera)))
|
||||
|
||||
(defn up [screen]
|
||||
"Returns the up vector of the camera in `screen`."
|
||||
(let [^Camera camera (u/get-obj screen :camera)]
|
||||
(. camera up)))
|
||||
|
||||
(defn up!
|
||||
"Sets the up vector of the camera in `screen`."
|
||||
[screen x-val y-val z-val]
|
||||
(let [^Camera camera (u/get-obj screen :camera)
|
||||
^Vector3 up-vec (up screen)]
|
||||
(some->> x-val (x! up-vec))
|
||||
(some->> y-val (y! up-vec))
|
||||
(some->> z-val (z! up-vec))
|
||||
(.update camera)))
|
||||
|
||||
(defn near
|
||||
|
||||
@@ -478,7 +478,7 @@ with the tiled map file at `path` and `unit` scale.
|
||||
|
||||
(defmethod draw! BatchTiledMapRenderer
|
||||
[{:keys [^BatchTiledMapRenderer renderer] :as screen} entities]
|
||||
(let [^Batch batch (.getSpriteBatch renderer)]
|
||||
(let [^Batch batch (.getBatch renderer)]
|
||||
(.begin batch)
|
||||
(doseq [entity entities]
|
||||
(e/draw! entity screen batch))
|
||||
@@ -610,7 +610,7 @@ to overlap correctly with the entities.
|
||||
(when-not (get-in screen [:layers ln])
|
||||
(update-fn! assoc-in [:layers ln] (split-layer screen ln))))
|
||||
(when camera (.setView renderer camera))
|
||||
(let [^Batch batch (.getSpriteBatch renderer)]
|
||||
(let [^Batch batch (.getBatch renderer)]
|
||||
(.begin batch)
|
||||
(doseq [entity (->> (map #(get-in screen [:layers %]) layer-names)
|
||||
(apply concat entities)
|
||||
|
||||
@@ -184,8 +184,6 @@ such as :on-begin-contact."
|
||||
(defmacro circle-shape
|
||||
"Returns a [CircleShape](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/physics/box2d/CircleShape.html)."
|
||||
[& options]
|
||||
(when (some-> (first options) keyword? not)
|
||||
(throw (Exception. "Replace (circle-shape radius) with (circle-shape :set-radius radius :set-position (vector-2 radius radius))")))
|
||||
`(u/calls! ^CircleShape (circle-shape*) ~@options))
|
||||
|
||||
(defmacro circle-shape!
|
||||
|
||||
@@ -153,7 +153,7 @@ new object to be created each time a field is set).
|
||||
|
||||
(defn gdx-array*
|
||||
[clj-arr]
|
||||
(Array. true (into-array clj-arr) 1 (count clj-arr)))
|
||||
(Array. (into-array clj-arr)))
|
||||
|
||||
(defmacro gdx-array
|
||||
"Returns an [Array](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/utils/Array.html).
|
||||
|
||||
Reference in New Issue
Block a user