Make update-fn! take variadic args
This commit is contained in:
@@ -77,7 +77,7 @@
|
|||||||
(update-screen! @screen)))))
|
(update-screen! @screen)))))
|
||||||
execute-fn-on-gl! (fn [& args]
|
execute-fn-on-gl! (fn [& args]
|
||||||
(on-gl (apply execute-fn! args)))
|
(on-gl (apply execute-fn! args)))
|
||||||
update-fn! (fn [func args]
|
update-fn! (fn [func & args]
|
||||||
(doto (apply swap! screen func args)
|
(doto (apply swap! screen func args)
|
||||||
update-screen!))]
|
update-screen!))]
|
||||||
{:screen screen
|
{:screen screen
|
||||||
@@ -92,21 +92,20 @@
|
|||||||
(some-> @screen :world :object .dispose)
|
(some-> @screen :world :object .dispose)
|
||||||
; set the initial values in the screen map
|
; set the initial values in the screen map
|
||||||
(update-fn! assoc
|
(update-fn! assoc
|
||||||
[:total-time 0
|
:total-time 0
|
||||||
:execute-fn! execute-fn!
|
:execute-fn! execute-fn!
|
||||||
:execute-fn-on-gl! execute-fn-on-gl!
|
:execute-fn-on-gl! execute-fn-on-gl!
|
||||||
:update-fn! update-fn!
|
:update-fn! update-fn!
|
||||||
:options options
|
:options options
|
||||||
:on-timer on-timer
|
:on-timer on-timer
|
||||||
:layers nil
|
:layers nil
|
||||||
:input-listeners (input-listeners options execute-fn!)
|
:input-listeners (input-listeners options execute-fn!)
|
||||||
:ui-listeners (ui-listeners options execute-fn!)])
|
:ui-listeners (ui-listeners options execute-fn!))
|
||||||
; run :on-show
|
; run :on-show
|
||||||
(execute-fn! on-show)
|
(execute-fn! on-show)
|
||||||
; update the physics contact listener if a :world was created
|
; update the physics contact listener if a :world was created
|
||||||
(some->> (contact-listener @screen options execute-fn!)
|
(some->> (contact-listener @screen options execute-fn!)
|
||||||
(vector :contact-listener)
|
(update-fn! assoc :contact-listener)))
|
||||||
(update-fn! assoc)))
|
|
||||||
:render (fn [d]
|
:render (fn [d]
|
||||||
(swap! screen #(assoc % :total-time (+ (:total-time %) d)))
|
(swap! screen #(assoc % :total-time (+ (:total-time %) d)))
|
||||||
(execute-fn! on-render :delta-time d))
|
(execute-fn! on-render :delta-time d))
|
||||||
@@ -550,7 +549,7 @@ is the atom storing the screen map behind the scenes. Returns the updated
|
|||||||
|
|
||||||
(update! screen :renderer (stage))"
|
(update! screen :renderer (stage))"
|
||||||
[screen & args]
|
[screen & args]
|
||||||
((:update-fn! screen) assoc args))
|
(apply (:update-fn! screen) assoc args))
|
||||||
|
|
||||||
(defn screen!
|
(defn screen!
|
||||||
"Runs a function defined in another screen. You may optionally pass a series
|
"Runs a function defined in another screen. You may optionally pass a series
|
||||||
|
|||||||
@@ -591,7 +591,7 @@ to overlap correctly with the entities.
|
|||||||
sort-fn layer-names entities]
|
sort-fn layer-names entities]
|
||||||
(doseq [ln layer-names]
|
(doseq [ln layer-names]
|
||||||
(when-not (get-in screen [:layers ln])
|
(when-not (get-in screen [:layers ln])
|
||||||
(update-fn! assoc-in [[:layers ln] (split-layer screen ln)])))
|
(update-fn! assoc-in [:layers ln] (split-layer screen ln))))
|
||||||
(when camera (.setView renderer camera))
|
(when camera (.setView renderer camera))
|
||||||
(let [^Batch batch (.getSpriteBatch renderer)]
|
(let [^Batch batch (.getSpriteBatch renderer)]
|
||||||
(.begin batch)
|
(.begin batch)
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ specified path.
|
|||||||
(some-> u/*timers* (swap! disj old-timer)))
|
(some-> u/*timers* (swap! disj old-timer)))
|
||||||
; create timer, add to screen map, and return it
|
; create timer, add to screen map, and return it
|
||||||
(let [new-timer (timer*)]
|
(let [new-timer (timer*)]
|
||||||
(update-fn! assoc-in [[:timers id] new-timer])
|
(update-fn! assoc-in [:timers id] new-timer)
|
||||||
(some-> u/*timers* (swap! conj new-timer))
|
(some-> u/*timers* (swap! conj new-timer))
|
||||||
new-timer))
|
new-timer))
|
||||||
|
|
||||||
@@ -147,7 +147,7 @@ found."
|
|||||||
[{:keys [update-fn!] :as screen} id]
|
[{:keys [update-fn!] :as screen} id]
|
||||||
(when-let [timer (get-in screen [:timers id])]
|
(when-let [timer (get-in screen [:timers id])]
|
||||||
(.stop timer)
|
(.stop timer)
|
||||||
(update-fn! update-in [[:timers] dissoc id])
|
(update-fn! update-in [:timers] dissoc id)
|
||||||
timer))
|
timer))
|
||||||
|
|
||||||
; assets
|
; assets
|
||||||
|
|||||||
Reference in New Issue
Block a user