Make update-fn! take variadic args
This commit is contained in:
@@ -77,7 +77,7 @@
|
||||
(update-screen! @screen)))))
|
||||
execute-fn-on-gl! (fn [& args]
|
||||
(on-gl (apply execute-fn! args)))
|
||||
update-fn! (fn [func args]
|
||||
update-fn! (fn [func & args]
|
||||
(doto (apply swap! screen func args)
|
||||
update-screen!))]
|
||||
{:screen screen
|
||||
@@ -92,21 +92,20 @@
|
||||
(some-> @screen :world :object .dispose)
|
||||
; set the initial values in the screen map
|
||||
(update-fn! assoc
|
||||
[:total-time 0
|
||||
:execute-fn! execute-fn!
|
||||
:execute-fn-on-gl! execute-fn-on-gl!
|
||||
:update-fn! update-fn!
|
||||
:options options
|
||||
:on-timer on-timer
|
||||
:layers nil
|
||||
:input-listeners (input-listeners options execute-fn!)
|
||||
:ui-listeners (ui-listeners options execute-fn!)])
|
||||
:total-time 0
|
||||
:execute-fn! execute-fn!
|
||||
:execute-fn-on-gl! execute-fn-on-gl!
|
||||
:update-fn! update-fn!
|
||||
:options options
|
||||
:on-timer on-timer
|
||||
:layers nil
|
||||
:input-listeners (input-listeners options execute-fn!)
|
||||
:ui-listeners (ui-listeners options execute-fn!))
|
||||
; run :on-show
|
||||
(execute-fn! on-show)
|
||||
; update the physics contact listener if a :world was created
|
||||
(some->> (contact-listener @screen options execute-fn!)
|
||||
(vector :contact-listener)
|
||||
(update-fn! assoc)))
|
||||
(update-fn! assoc :contact-listener)))
|
||||
:render (fn [d]
|
||||
(swap! screen #(assoc % :total-time (+ (:total-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))"
|
||||
[screen & args]
|
||||
((:update-fn! screen) assoc args))
|
||||
(apply (:update-fn! screen) assoc args))
|
||||
|
||||
(defn screen!
|
||||
"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]
|
||||
(doseq [ln layer-names]
|
||||
(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))
|
||||
(let [^Batch batch (.getSpriteBatch renderer)]
|
||||
(.begin batch)
|
||||
|
||||
@@ -114,7 +114,7 @@ specified path.
|
||||
(some-> u/*timers* (swap! disj old-timer)))
|
||||
; create timer, add to screen map, and return it
|
||||
(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))
|
||||
new-timer))
|
||||
|
||||
@@ -147,7 +147,7 @@ found."
|
||||
[{:keys [update-fn!] :as screen} id]
|
||||
(when-let [timer (get-in screen [:timers id])]
|
||||
(.stop timer)
|
||||
(update-fn! update-in [[:timers] dissoc id])
|
||||
(update-fn! update-in [:timers] dissoc id)
|
||||
timer))
|
||||
|
||||
; assets
|
||||
|
||||
Reference in New Issue
Block a user