Fix camera behavior

This commit is contained in:
oakes
2014-04-07 11:26:10 -04:00
parent 8d0502560a
commit 6a3bbf07b6
2 changed files with 6 additions and 5 deletions

View File

@@ -39,15 +39,13 @@
(u/call! object# ~k ~@options)))
(defn size!
"Sets the size of the camera in `screen` and recenters it.
"Sets the size of the camera in `screen`.
(size! screen 480 360)"
[screen width height]
(let [^Camera camera (u/get-obj screen :camera)]
(set! (. camera viewportWidth) width)
(set! (. camera viewportHeight) height)
(set! (. (. camera position) x) (/ width 2))
(set! (. (. camera position) y) (/ height 2))
(.update camera)))
(defn width

View File

@@ -163,7 +163,8 @@
; g2d-physics
(defn ^:private contact-listener
[{:keys [on-begin-contact on-end-contact on-post-solve on-pre-solve]} execute-fn!]
[{:keys [on-begin-contact on-end-contact on-post-solve on-pre-solve]}
execute-fn!]
(reify ContactListener
(beginContact [this c]
(execute-fn! on-begin-contact :contact c))
@@ -180,7 +181,9 @@
([{:keys [^Stage renderer ^Camera camera] :as screen}]
(when camera
(doto (.getViewport renderer)
(.setCamera camera))))
(.setCamera camera)
(.setWorldSize (. camera viewportWidth) (. camera viewportHeight))
(.update (game :width) (game :height) true))))
([{:keys [^Stage renderer ui-listeners]} entities]
(doseq [^Actor a (.getActors renderer)]
(.remove a))