Allow width and height to work without a camera
This commit is contained in:
@@ -50,12 +50,16 @@
|
|||||||
(.update camera)))
|
(.update camera)))
|
||||||
|
|
||||||
(defn width
|
(defn width
|
||||||
"Returns the width of the camera in `screen`.
|
"Returns the width of the camera in `screen`. If there is no camera, it
|
||||||
|
returns the overall width.
|
||||||
|
|
||||||
(width screen)"
|
(width screen)"
|
||||||
[screen]
|
[screen]
|
||||||
(let [^Camera camera (u/get-obj screen :camera)]
|
(try
|
||||||
(. camera viewportWidth)))
|
(let [^Camera camera (u/get-obj screen :camera)]
|
||||||
|
(. camera viewportWidth))
|
||||||
|
(catch Exception _
|
||||||
|
(game :width))))
|
||||||
|
|
||||||
(defn width!
|
(defn width!
|
||||||
"Sets the width of the camera in `screen`, adjusting the height so the ratio
|
"Sets the width of the camera in `screen`, adjusting the height so the ratio
|
||||||
@@ -66,12 +70,16 @@ remains in tact.
|
|||||||
(size! screen new-width (* new-width (/ (game :height) (game :width)))))
|
(size! screen new-width (* new-width (/ (game :height) (game :width)))))
|
||||||
|
|
||||||
(defn height
|
(defn height
|
||||||
"Returns the height of the camera in `screen`.
|
"Returns the height of the camera in `screen`. If there is no camera, it
|
||||||
|
returns the overall height.
|
||||||
|
|
||||||
(height screen)"
|
(height screen)"
|
||||||
[screen]
|
[screen]
|
||||||
(let [^Camera camera (u/get-obj screen :camera)]
|
(try
|
||||||
(. camera viewportHeight)))
|
(let [^Camera camera (u/get-obj screen :camera)]
|
||||||
|
(. camera viewportHeight))
|
||||||
|
(catch Exception _
|
||||||
|
(game :height))))
|
||||||
|
|
||||||
(defn height!
|
(defn height!
|
||||||
"Sets the height of the camera in `screen`, adjusting the width so the ratio
|
"Sets the height of the camera in `screen`, adjusting the width so the ratio
|
||||||
|
|||||||
Reference in New Issue
Block a user