(add-timer! screen id delay)
(add-timer! screen id delay interval)
(add-timer! screen id delay interval repeat)
Returns a Timer which will fire the :on-timer function one or more times (depending on the given arguments). In the :on-timer function, the id will be passed in the screen map. If a timer with that id already exists in the screen, it will be stopped and replaced with a new timer.
; wait 2 seconds and run once
(add-timer! screen :spawn-enemy 2)
; wait 2 seconds and run forever at 10 second intervals
(add-timer! screen :spawn-enemy 2 10)
; wait 2 seconds, run once, and then run 3 more times at 10 second intervals
(add-timer! screen :spawn-enemy 2 10 3)
Returns a [Timer](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/utils/Timer.html) which will fire the :on-timer function one or more times (depending on the given arguments). In the :on-timer function, the id will be passed in the screen map. If a timer with that id already exists in the screen, it will be stopped and replaced with a new timer. ; wait 2 seconds and run once (add-timer! screen :spawn-enemy 2) ; wait 2 seconds and run forever at 10 second intervals (add-timer! screen :spawn-enemy 2 10) ; wait 2 seconds, run once, and then run 3 more times at 10 second intervals (add-timer! screen :spawn-enemy 2 10 3)
(app! k & options)
Calls a single method on Gdx.app.
(app! :error "MYTAG" "An error occurred, so I'm logging it!")
Calls a single method on [Gdx.app](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/Application.html). (app! :error "MYTAG" "An error occurred, so I'm logging it!")
(asset-manager & options)
Returns an AssetManager.
(asset-manager)
Returns an [AssetManager](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/assets/AssetManager.html). (asset-manager)
(asset-manager! object k & options)
Calls a single method in an asset-manager
.
(asset-manager! object :clear)
Calls a single method in an `asset-manager`. (asset-manager! object :clear)
(audio! k & options)
Calls a single method on Gdx.audio.
(audio! :new-audio-recorder 44100 false)
Calls a single method on [Gdx.audio](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/Audio.html). (audio! :new-audio-recorder 44100 false)
(bundle & entities)
Returns an entity containing other entities. This is a useful way to keep related entities together. They will be drawn in the order they appear in the internal :entities vector. Any keys in the bundle, such as :x and :y, will be passed down to all the internal entities unless they already have those keys.
(bundle (shape :filled) (shape :line))
(assoc (bundle (shape :filled) (shape :line))
:x 100 :y 100)
Returns an entity containing other entities. This is a useful way to keep related entities together. They will be drawn in the order they appear in the internal :entities vector. Any keys in the bundle, such as :x and :y, will be passed down to all the internal entities unless they already have those keys. (bundle (shape :filled) (shape :line)) (assoc (bundle (shape :filled) (shape :line)) :x 100 :y 100)
(bundle? entity)
Returns true if entity
is a bundle
.
Returns true if `entity` is a `bundle`.
(button-code k)
Returns a static field from Input.Buttons.
(button-code :left)
Returns a static field from [Input.Buttons](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/Input.Buttons.html). (button-code :left)
(button-pressed? k)
Returns a boolean indicating if the button cooresponding to k
is being pressed.
(button-pressed? :left)
Returns a boolean indicating if the button cooresponding to `k` is being pressed. (button-pressed? :left)
(clear!)
(clear! r g b a)
Clears the screen with a uniform color, defaulting to black.
(clear!) (clear! 0.5 0.5 1 1)
Clears the screen with a uniform color, defaulting to black. (clear!) (clear! 0.5 0.5 1 1)
(color & args)
Returns a Color.
(color :white) (color 1 1 1 1)
Returns a [Color](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/Color.html). (color :white) (color 1 1 1 1)
(color! object k & options)
Calls a single method on a color
.
Calls a single method on a `color`.
(defgame n & {:keys [] :as options})
Defines a game. This should only be called once.
Defines a game. This should only be called once.
(defscreen n & options)
Defines a screen, and creates vars for all the functions inside of it. All functions take a screen map and entities vector as arguments, and return the entities list at the end with any desired changes. If a function returns nil, the entities list is not changed.
Below are all the possible screen functions. Some of them get special arguments via the screen map.
; main screen functions
(defscreen my-screen
; the screen first shows
:on-show
(fn [screen entities]
entities)
; the screen must be rendered (many times per second)
:on-render
(fn [screen entities]
(println (:delta-time screen)) ; time (ms) elapsed since last frame
(println (:total-time screen)) ; time (ms) elapsed since first :on-show
entities)
; the screen was replaced
:on-hide
(fn [screen entities]
entities)
; the screen was resized
:on-resize
(fn [screen entities]
(println (:width screen)) ; the new width of the screen
(println (:height screen)) ; the new height of the screen
entities)
; the screen resumed from a paused state
:on-resume
(fn [screen entities]
entities)
; the screen paused
:on-pause
(fn [screen entities]
entities)
; a timer created with add-timer! executed
:on-timer
(fn [screen entities]
(println (:id screen)) ; the id supplied when the timer was created
entities))
; input functions
; 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
(fn [screen entities]
(println (:key screen)) ; the key that was pressed (see key-code)
entities)
; a key was typed
:on-key-typed
(fn [screen entities]
(println (:character screen)) ; the character that was pressed
entities)
; a key was released
:on-key-up
(fn [screen entities]
(println (:key screen)) ; the key that was released (see key-code)
entities)
; the mouse was moved without pressing any buttons
:on-mouse-moved
(fn [screen entities]
(println (:input-x screen)) ; the x position of the mouse
(println (:input-y screen)) ; the y position of the mouse
entities)
; the mouse wheel was scrolled
:on-scrolled
(fn [screen entities]
(println (:amount screen)) ; the amount scrolled
entities)
; the screen was touched or a mouse button was pressed
:on-touch-down
(fn [screen entities]
(println (:input-x screen)) ; the x position of the finger/mouse
(println (:input-y screen)) ; the y position of the finger/mouse
(println (:pointer screen)) ; the pointer for the event
(println (:button screen)) ; the mouse button that was pressed (see button-code)
entities)
; a finger or the mouse was dragged
:on-touch-dragged
(fn [screen entities]
(println (:input-x screen)) ; the x position of the finger/mouse
(println (:input-y screen)) ; the y position of the finger/mouse
(println (:pointer screen)) ; the pointer for the event
entities)
; a finger was lifted or a mouse button was released
:on-touch-up
(fn [screen entities]
(println (:input-x screen)) ; the x position of the finger/mouse
(println (:input-y screen)) ; the y position of the finger/mouse
(println (:pointer screen)) ; the pointer for the event
(println (:button screen)) ; the mouse button that was released (see button-code)
entities))
; gesture functions
(defscreen my-screen
; the user dragged over the screen and lifted
:on-fling
(fn [screen entities]
(println (:velocity-x screen)) ; the x-axis velocity (s)
(println (:velocity-y screen)) ; the y-axis velocity (s)
(println (:button screen)) ; the mouse button that was pressed (see button-code)
entities)
; the user pressed for a long time
:on-long-press
(fn [screen entities]
(println (:input-x screen)) ; the x position of the finger/mouse
(println (:input-y screen)) ; the y position of the finger/mouse
entities)
; the user dragged a finger over the screen
:on-pan
(fn [screen entities]
(println (:input-x screen)) ; the x position of the finger/mouse
(println (:input-y screen)) ; the y position of the finger/mouse
(println (:delta-x screen)) ; the x-axis distance moved
(println (:delta-y screen)) ; the y-axis distance moved
entities)
; the user is no longer panning
:on-pan-stop
(fn [screen entities]
(println (:input-x screen)) ; the x position of the finger/mouse
(println (:input-y screen)) ; the y position of the finger/mouse
(println (:pointer screen)) ; the pointer for the event
(println (:button screen)) ; the mouse button that was pressed (see button-code)
entities)
; the user performed a pinch zoom gesture
:on-pinch
(fn [screen entities]
(println (:initial-pointer-1 screen)) ; the start position of finger 1 (see the x and y functions)
(println (:initial-pointer-2 screen)) ; the start position of finger 2 (see the x and y functions)
(println (:pointer-1 screen)) ; the end position of finger 1 (see the x and y functions)
(println (:pointer-2 screen)) ; the end position of finger 2 (see the x and y functions)
entities)
; the user tapped
:on-tap
(fn [screen entities]
(println (:input-x screen)) ; the x position of the finger/mouse
(println (:input-y screen)) ; the y position of the finger/mouse
(println (:count screen)) ; the number of taps
(println (:button screen)) ; the mouse button that was pressed (see button-code)
entities)
; the user performed a pinch zoom gesture
:on-zoom
(fn [screen entities]
(println (:initial-distance screen)) ; the start distance between fingers
(println (:distance screen)) ; the end distance between fingers
entities))
; 2D physics contact (for play-clj.g2d-physics)
; Tip: use first-entity and second-entity to get the entities that are contacting
(defscreen my-screen
; two bodies began to touch
:on-begin-contact
(fn [screen entities]
(println (:contact screen)) ; the Contact - http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/physics/box2d/Contact.html
entities)
; two bodies ceased to touch
:on-end-contact
(fn [screen entities]
(println (:contact screen)) ; the Contact - http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/physics/box2d/Contact.html
entities)
; called between each use of `step!` before the collision is processed
:on-pre-solve
(fn [screen entities]
(println (:contact screen)) ; the Contact - http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/physics/box2d/Contact.html
(println (:impulse screen)) ; the ContactImpulse - http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/physics/box2d/ContactImpulse.html
entities)
; called between each use of `step!` after the collision is processed
:on-post-solve
(fn [screen entities]
(println (:contact screen)) ; the Contact - http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/physics/box2d/Contact.html
(println (:old-manifold screen)) ; the Manifold - http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/physics/box2d/Manifold.html
entities))
; 3D physics contact (for play-clj.g3d-physics)
; Tip: use first-entity and second-entity to get the entities that are contacting
(defscreen my-screen
; two bodies began to touch
:on-begin-contact
(fn [screen entities]
(println (:first-body screen)) ; the first btCollisionObject - http://bulletphysics.org/Bullet/BulletFull/classbtCollisionObject.html
(println (:second-body screen)) ; the second btCollisionObject - http://bulletphysics.org/Bullet/BulletFull/classbtCollisionObject.html
entities)
; two bodies ceased to touch
:on-end-contact
(fn [screen entities]
(println (:first-body screen)) ; the first btCollisionObject - http://bulletphysics.org/Bullet/BulletFull/classbtCollisionObject.html
(println (:second-body screen)) ; the second btCollisionObject - http://bulletphysics.org/Bullet/BulletFull/classbtCollisionObject.html
entities))
; ui input functions (for play-clj.ui)
(defscreen my-screen
; 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 finger/mouse moved over the ui entity
:on-ui-enter
(fn [screen entities]
(println (:event screen)) ; the InputEvent - http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/InputEvent.html
(println (:actor screen)) ; the Actor - http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/Actor.html
(println (:input-x screen)) ; the x position of the finger/mouse
(println (:input-y screen)) ; the y position of the finger/mouse
(println (:pointer screen)) ; the pointer for the event
entities)
; the finger/mouse moved out of the ui entity
:on-ui-exit
(fn [screen entities]
(println (:event screen)) ; the InputEvent - http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/InputEvent.html
(println (:actor screen)) ; the Actor - http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/Actor.html
(println (:input-x screen)) ; the x position of the finger/mouse
(println (:input-y screen)) ; the y position of the finger/mouse
(println (:pointer screen)) ; the pointer for the event
entities)
; the finger/mouse went down on the ui entity
:on-ui-touch-down
(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
(println (:pointer screen)) ; the pointer for the event
(println (:button screen)) ; the mouse button that was pressed (see button-code)
entities)
; the finger/mouse moved anywhere
:on-ui-touch-dragged
(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
(println (:pointer screen)) ; the pointer for the event
entities)
; the finger/mouse went up anywhere
:on-ui-touch-up
(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
(println (:pointer screen)) ; the pointer for the event
(println (:button screen)) ; the mouse button that was released (see button-code)
entities))
; ui drag functions (for play-clj.ui)
(defscreen my-screen
:on-ui-drag
(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
(println (:pointer screen)) ; the pointer for the event
entities)
:on-ui-drag-start
(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
(println (:pointer screen)) ; the pointer for the event
entities)
:on-ui-drag-stop
(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
(println (:pointer screen)) ; the pointer for the event
entities))
; ui focus functions (for play-clj.ui)
(defscreen my-screen
:on-ui-keyboard-focus-changed
(fn [screen entities]
(println (:event screen)) ; the FocusListener.FocusEvent - http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/utils/FocusListener.FocusEvent.html
(println (:actor screen)) ; the Actor - http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/Actor.html
(println (:focused? screen)) ; whether it is focused
entities)
:on-ui-scroll-focus-changed
(fn [screen entities]
(println (:event screen)) ; the FocusListener.FocusEvent - http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/utils/FocusListener.FocusEvent.html
(println (:actor screen)) ; the Actor - http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/Actor.html
(println (:focused? screen)) ; whether it is focused
entities))
; ui gesture functions (for play-clj.ui)
(defscreen my-screen
; the user dragged a finger over the screen and lifted it
:on-ui-fling
(fn [screen entities]
(println (:event screen)) ; the InputEvent - http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/InputEvent.html
(println (:velocity-x screen)) ; the x-axis velocity (s)
(println (:velocity-y screen)) ; the y-axis velocity (s)
(println (:button screen)) ; the mouse button that was pressed (see button-code)
entities)
; the user pressed
:on-ui-long-press
(fn [screen entities]
(println (:actor screen)) ; the Actor - http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/Actor.html
(println (:input-x screen)) ; the x position of the finger
(println (:input-y screen)) ; the y position of the finger
entities)
; the user dragged a finger over the screen
:on-ui-pan
(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
(println (:input-y screen)) ; the y position of the finger
(println (:delta-x screen)) ; the x-axis distance moved
(println (:delta-y screen)) ; the y-axis distance moved
entities)
; the user is no longer panning
:on-ui-pan-stop
(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
(println (:input-y screen)) ; the y position of the finger
(println (:pointer screen)) ; the pointer for the event
(println (:button screen)) ; the mouse button that was pressed (see button-code)
entities)
; the user performed a pinch zoom gesture
:on-ui-pinch
(fn [screen entities]
(println (:event screen)) ; the InputEvent - http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/InputEvent.html
(println (:initial-pointer-1 screen)) ; the start position of finger 1 (see the x and y functions)
(println (:initial-pointer-2 screen)) ; the start position of finger 2 (see the x and y functions)
(println (:pointer-1 screen)) ; the end position of finger 1 (see the x and y functions)
(println (:pointer-2 screen)) ; the end position of finger 2 (see the x and y functions)
entities)
; the user tapped
:on-ui-tap
(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
(println (:input-y screen)) ; the y position of the finger
(println (:count screen)) ; the number of taps
(println (:button screen)) ; the mouse button that was pressed (see button-code)
entities)
; the user performed a pinch zoom gesture
:on-ui-zoom
(fn [screen entities]
(println (:event screen)) ; the InputEvent - http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/InputEvent.html
(println (:initial-distance screen)) ; the start distance between fingers
(println (:distance screen)) ; the end distance between fingers
entities))
Defines a screen, and creates vars for all the functions inside of it. All functions take a screen map and entities vector as arguments, and return the entities list at the end with any desired changes. If a function returns nil, the entities list is not changed. Below are all the possible screen functions. Some of them get special arguments via the screen map. ; main screen functions (defscreen my-screen ; the screen first shows :on-show (fn [screen entities] entities) ; the screen must be rendered (many times per second) :on-render (fn [screen entities] (println (:delta-time screen)) ; time (ms) elapsed since last frame (println (:total-time screen)) ; time (ms) elapsed since first :on-show entities) ; the screen was replaced :on-hide (fn [screen entities] entities) ; the screen was resized :on-resize (fn [screen entities] (println (:width screen)) ; the new width of the screen (println (:height screen)) ; the new height of the screen entities) ; the screen resumed from a paused state :on-resume (fn [screen entities] entities) ; the screen paused :on-pause (fn [screen entities] entities) ; a timer created with add-timer! executed :on-timer (fn [screen entities] (println (:id screen)) ; the id supplied when the timer was created entities)) ; input functions ; 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 (fn [screen entities] (println (:key screen)) ; the key that was pressed (see key-code) entities) ; a key was typed :on-key-typed (fn [screen entities] (println (:character screen)) ; the character that was pressed entities) ; a key was released :on-key-up (fn [screen entities] (println (:key screen)) ; the key that was released (see key-code) entities) ; the mouse was moved without pressing any buttons :on-mouse-moved (fn [screen entities] (println (:input-x screen)) ; the x position of the mouse (println (:input-y screen)) ; the y position of the mouse entities) ; the mouse wheel was scrolled :on-scrolled (fn [screen entities] (println (:amount screen)) ; the amount scrolled entities) ; the screen was touched or a mouse button was pressed :on-touch-down (fn [screen entities] (println (:input-x screen)) ; the x position of the finger/mouse (println (:input-y screen)) ; the y position of the finger/mouse (println (:pointer screen)) ; the pointer for the event (println (:button screen)) ; the mouse button that was pressed (see button-code) entities) ; a finger or the mouse was dragged :on-touch-dragged (fn [screen entities] (println (:input-x screen)) ; the x position of the finger/mouse (println (:input-y screen)) ; the y position of the finger/mouse (println (:pointer screen)) ; the pointer for the event entities) ; a finger was lifted or a mouse button was released :on-touch-up (fn [screen entities] (println (:input-x screen)) ; the x position of the finger/mouse (println (:input-y screen)) ; the y position of the finger/mouse (println (:pointer screen)) ; the pointer for the event (println (:button screen)) ; the mouse button that was released (see button-code) entities)) ; gesture functions (defscreen my-screen ; the user dragged over the screen and lifted :on-fling (fn [screen entities] (println (:velocity-x screen)) ; the x-axis velocity (s) (println (:velocity-y screen)) ; the y-axis velocity (s) (println (:button screen)) ; the mouse button that was pressed (see button-code) entities) ; the user pressed for a long time :on-long-press (fn [screen entities] (println (:input-x screen)) ; the x position of the finger/mouse (println (:input-y screen)) ; the y position of the finger/mouse entities) ; the user dragged a finger over the screen :on-pan (fn [screen entities] (println (:input-x screen)) ; the x position of the finger/mouse (println (:input-y screen)) ; the y position of the finger/mouse (println (:delta-x screen)) ; the x-axis distance moved (println (:delta-y screen)) ; the y-axis distance moved entities) ; the user is no longer panning :on-pan-stop (fn [screen entities] (println (:input-x screen)) ; the x position of the finger/mouse (println (:input-y screen)) ; the y position of the finger/mouse (println (:pointer screen)) ; the pointer for the event (println (:button screen)) ; the mouse button that was pressed (see button-code) entities) ; the user performed a pinch zoom gesture :on-pinch (fn [screen entities] (println (:initial-pointer-1 screen)) ; the start position of finger 1 (see the x and y functions) (println (:initial-pointer-2 screen)) ; the start position of finger 2 (see the x and y functions) (println (:pointer-1 screen)) ; the end position of finger 1 (see the x and y functions) (println (:pointer-2 screen)) ; the end position of finger 2 (see the x and y functions) entities) ; the user tapped :on-tap (fn [screen entities] (println (:input-x screen)) ; the x position of the finger/mouse (println (:input-y screen)) ; the y position of the finger/mouse (println (:count screen)) ; the number of taps (println (:button screen)) ; the mouse button that was pressed (see button-code) entities) ; the user performed a pinch zoom gesture :on-zoom (fn [screen entities] (println (:initial-distance screen)) ; the start distance between fingers (println (:distance screen)) ; the end distance between fingers entities)) ; 2D physics contact (for play-clj.g2d-physics) ; Tip: use first-entity and second-entity to get the entities that are contacting (defscreen my-screen ; two bodies began to touch :on-begin-contact (fn [screen entities] (println (:contact screen)) ; the Contact - http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/physics/box2d/Contact.html entities) ; two bodies ceased to touch :on-end-contact (fn [screen entities] (println (:contact screen)) ; the Contact - http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/physics/box2d/Contact.html entities) ; called between each use of `step!` before the collision is processed :on-pre-solve (fn [screen entities] (println (:contact screen)) ; the Contact - http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/physics/box2d/Contact.html (println (:impulse screen)) ; the ContactImpulse - http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/physics/box2d/ContactImpulse.html entities) ; called between each use of `step!` after the collision is processed :on-post-solve (fn [screen entities] (println (:contact screen)) ; the Contact - http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/physics/box2d/Contact.html (println (:old-manifold screen)) ; the Manifold - http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/physics/box2d/Manifold.html entities)) ; 3D physics contact (for play-clj.g3d-physics) ; Tip: use first-entity and second-entity to get the entities that are contacting (defscreen my-screen ; two bodies began to touch :on-begin-contact (fn [screen entities] (println (:first-body screen)) ; the first btCollisionObject - http://bulletphysics.org/Bullet/BulletFull/classbtCollisionObject.html (println (:second-body screen)) ; the second btCollisionObject - http://bulletphysics.org/Bullet/BulletFull/classbtCollisionObject.html entities) ; two bodies ceased to touch :on-end-contact (fn [screen entities] (println (:first-body screen)) ; the first btCollisionObject - http://bulletphysics.org/Bullet/BulletFull/classbtCollisionObject.html (println (:second-body screen)) ; the second btCollisionObject - http://bulletphysics.org/Bullet/BulletFull/classbtCollisionObject.html entities)) ; ui input functions (for play-clj.ui) (defscreen my-screen ; 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 finger/mouse moved over the ui entity :on-ui-enter (fn [screen entities] (println (:event screen)) ; the InputEvent - http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/InputEvent.html (println (:actor screen)) ; the Actor - http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/Actor.html (println (:input-x screen)) ; the x position of the finger/mouse (println (:input-y screen)) ; the y position of the finger/mouse (println (:pointer screen)) ; the pointer for the event entities) ; the finger/mouse moved out of the ui entity :on-ui-exit (fn [screen entities] (println (:event screen)) ; the InputEvent - http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/InputEvent.html (println (:actor screen)) ; the Actor - http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/Actor.html (println (:input-x screen)) ; the x position of the finger/mouse (println (:input-y screen)) ; the y position of the finger/mouse (println (:pointer screen)) ; the pointer for the event entities) ; the finger/mouse went down on the ui entity :on-ui-touch-down (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 (println (:pointer screen)) ; the pointer for the event (println (:button screen)) ; the mouse button that was pressed (see button-code) entities) ; the finger/mouse moved anywhere :on-ui-touch-dragged (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 (println (:pointer screen)) ; the pointer for the event entities) ; the finger/mouse went up anywhere :on-ui-touch-up (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 (println (:pointer screen)) ; the pointer for the event (println (:button screen)) ; the mouse button that was released (see button-code) entities)) ; ui drag functions (for play-clj.ui) (defscreen my-screen :on-ui-drag (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 (println (:pointer screen)) ; the pointer for the event entities) :on-ui-drag-start (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 (println (:pointer screen)) ; the pointer for the event entities) :on-ui-drag-stop (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 (println (:pointer screen)) ; the pointer for the event entities)) ; ui focus functions (for play-clj.ui) (defscreen my-screen :on-ui-keyboard-focus-changed (fn [screen entities] (println (:event screen)) ; the FocusListener.FocusEvent - http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/utils/FocusListener.FocusEvent.html (println (:actor screen)) ; the Actor - http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/Actor.html (println (:focused? screen)) ; whether it is focused entities) :on-ui-scroll-focus-changed (fn [screen entities] (println (:event screen)) ; the FocusListener.FocusEvent - http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/utils/FocusListener.FocusEvent.html (println (:actor screen)) ; the Actor - http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/Actor.html (println (:focused? screen)) ; whether it is focused entities)) ; ui gesture functions (for play-clj.ui) (defscreen my-screen ; the user dragged a finger over the screen and lifted it :on-ui-fling (fn [screen entities] (println (:event screen)) ; the InputEvent - http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/InputEvent.html (println (:velocity-x screen)) ; the x-axis velocity (s) (println (:velocity-y screen)) ; the y-axis velocity (s) (println (:button screen)) ; the mouse button that was pressed (see button-code) entities) ; the user pressed :on-ui-long-press (fn [screen entities] (println (:actor screen)) ; the Actor - http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/Actor.html (println (:input-x screen)) ; the x position of the finger (println (:input-y screen)) ; the y position of the finger entities) ; the user dragged a finger over the screen :on-ui-pan (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 (println (:input-y screen)) ; the y position of the finger (println (:delta-x screen)) ; the x-axis distance moved (println (:delta-y screen)) ; the y-axis distance moved entities) ; the user is no longer panning :on-ui-pan-stop (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 (println (:input-y screen)) ; the y position of the finger (println (:pointer screen)) ; the pointer for the event (println (:button screen)) ; the mouse button that was pressed (see button-code) entities) ; the user performed a pinch zoom gesture :on-ui-pinch (fn [screen entities] (println (:event screen)) ; the InputEvent - http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/InputEvent.html (println (:initial-pointer-1 screen)) ; the start position of finger 1 (see the x and y functions) (println (:initial-pointer-2 screen)) ; the start position of finger 2 (see the x and y functions) (println (:pointer-1 screen)) ; the end position of finger 1 (see the x and y functions) (println (:pointer-2 screen)) ; the end position of finger 2 (see the x and y functions) entities) ; the user tapped :on-ui-tap (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 (println (:input-y screen)) ; the y position of the finger (println (:count screen)) ; the number of taps (println (:button screen)) ; the mouse button that was pressed (see button-code) entities) ; the user performed a pinch zoom gesture :on-ui-zoom (fn [screen entities] (println (:event screen)) ; the InputEvent - http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/InputEvent.html (println (:initial-distance screen)) ; the start distance between fingers (println (:distance screen)) ; the end distance between fingers entities))
(defscreen* screen
entities
{:keys [on-show on-render on-hide on-pause on-resize on-resume
on-timer]
:as options})
(direction screen)
Returns the direction of the camera in screen
.
Returns the direction of the camera in `screen`.
(direction! screen x-val y-val z-val)
(direction! screen x-val y-val z-val look-at?)
Sets the direction of the camera in screen
.
Sets the direction of the camera in `screen`.
(far screen)
Returns the far clipping plane distance of the camera in screen
.
Returns the far clipping plane distance of the camera in `screen`.
(far! screen n)
Sets the far clipping plane distance of the camera in screen
.
Sets the far clipping plane distance of the camera in `screen`.
(files! k & options)
Calls a single method on Gdx.files.
(files! :internal "image.png")
Calls a single method on [Gdx.files](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/Files.html). (files! :internal "image.png")
(find-first match-fn entities)
Returns the first entity in entities
for which match-fn
returns true.
(find-first :player? entities) (find-first #(= :menu (:id %)) entities)
Returns the first entity in `entities` for which `match-fn` returns true. (find-first :player? entities) (find-first #(= :menu (:id %)) entities)
(game k & [arg])
Provides quick access to often-used functions.
(game :width)
Provides quick access to often-used functions. (game :width)
(gesture-detector! screen k & options)
Calls a single method on the GestureDetector
in the screen
.
Calls a single method on the [GestureDetector](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/input/GestureDetector.html) in the `screen`.
(gl k)
Returns a static field from GL20.
(gl :gl-triangles)
Returns a static field from [GL20](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/GL20.html). (gl :gl-triangles)
(gl! k & options)
Calls a single method on Gdx.gl20.
(gl! :gl-create-program)
Calls a single method on [Gdx.gl20](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/GL20.html). (gl! :gl-create-program)
(graphics! k & options)
Calls a single method on Gdx.graphics.
(graphics! :is-fullscreen)
Calls a single method on [Gdx.graphics](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/Graphics.html). (graphics! :is-fullscreen)
(height screen)
Returns the height of the camera in screen
. If there is no camera, it
returns the overall height.
(height screen)
Returns the height of the camera in `screen`. If there is no camera, it returns the overall height. (height screen)
(height! screen new-height)
Sets the height of the camera in screen
, adjusting the width so the ratio
remains in tact.
(height! screen 360)
Sets the height of the camera in `screen`, adjusting the width so the ratio remains in tact. (height! screen 360)
(hexagonal-tiled-map path unit & options)
Returns a HexagonalTiledMapRenderer
with the tiled map file at path
and unit
scale.
(hexagonal-tiled-map "level1.tmx" (/ 1 8))
Returns a [HexagonalTiledMapRenderer](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/maps/tiled/renderers/HexagonalTiledMapRenderer.html) with the tiled map file at `path` and `unit` scale. (hexagonal-tiled-map "level1.tmx" (/ 1 8))
(hexagonal-tiled-map! screen k & options)
Calls a single method on a hexagonal-tiled-map
.
Calls a single method on a `hexagonal-tiled-map`.
(input! k & options)
Calls a single method on Gdx.input.
(input! :is-touched)
Calls a single method on [Gdx.input](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/Input.html). (input! :is-touched)
(input->screen screen {:keys [x y z] :or {x 0 y 0 z 0} :as entity})
(input->screen screen x y)
(input->screen screen x y z)
Returns a map with the provided x,y,z values converted from input to screen coordinates.
(input->screen screen {:x 10 :y 10 :z 0})
(input->screen screen 10 10)
(input->screen screen 10 10 0)
Returns a map with the provided x,y,z values converted from input to screen coordinates. (input->screen screen {:x 10 :y 10 :z 0}) (input->screen screen 10 10) (input->screen screen 10 10 0)
(input-processor! screen k & options)
Calls a single method on the InputProcessor
in the screen
.
Calls a single method on the [InputProcessor](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/InputProcessor.html) in the `screen`.
(isometric->screen screen {:keys [x y] :as entity})
(isometric->screen screen x y)
Returns a map with the provided x,y values converted from isometric map to screen coordinates.
(isometric->screen screen {:x 2 :y 1})
(isometric->screen screen 2 1)
Returns a map with the provided x,y values converted from isometric map to screen coordinates. (isometric->screen screen {:x 2 :y 1}) (isometric->screen screen 2 1)
(isometric-staggered-tiled-map path unit & options)
Returns an IsometricStaggeredTiledMapRenderer
with the tiled map file at path
and unit
scale.
(isometric-staggered-tiled-map "level1.tmx" (/ 1 8))
Returns an [IsometricStaggeredTiledMapRenderer](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/maps/tiled/renderers/IsometricStaggeredTiledMapRenderer.html) with the tiled map file at `path` and `unit` scale. (isometric-staggered-tiled-map "level1.tmx" (/ 1 8))
(isometric-staggered-tiled-map! screen k & options)
Calls a single method on an isometric-staggered-tiled-map
.
Calls a single method on an `isometric-staggered-tiled-map`.
(isometric-tiled-map path unit & options)
Returns an IsometricTiledMapRenderer
with the tiled map file at path
and unit
scale.
(isometric-tiled-map "level1.tmx" (/ 1 8))
Returns an [IsometricTiledMapRenderer](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/maps/tiled/renderers/IsometricTiledMapRenderer.html) with the tiled map file at `path` and `unit` scale. (isometric-tiled-map "level1.tmx" (/ 1 8))
(isometric-tiled-map! screen k & options)
Calls a single method on an isometric-tiled-map
.
Calls a single method on an `isometric-tiled-map`.
(key-code k)
Returns a static field from Input.Keys.
(key-code :a) (key-code :page-down)
Returns a static field from [Input.Keys](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/Input.Keys.html). (key-code :a) (key-code :page-down)
(key-pressed? k)
Returns a boolean indicating if the key cooresponding to k
is being pressed.
(key-pressed? :a) (key-pressed? :page-down)
Returns a boolean indicating if the key cooresponding to `k` is being pressed. (key-pressed? :a) (key-pressed? :page-down)
(map-layer screen layer & options)
Returns a MapLayer
from the tiled map in screen
that matches layer
. This is necessary for
non-tile layers, like object and image layers.
(map-layer screen "objects")
Returns a [MapLayer](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/maps/MapLayer.html) from the tiled map in `screen` that matches `layer`. This is necessary for non-tile layers, like object and image layers. (map-layer screen "objects")
(map-layer! object k & options)
Calls a single method on a map-layer
.
(map-layer! (map-layer screen "objects") :set-visible false)
Calls a single method on a `map-layer`. (map-layer! (map-layer screen "objects") :set-visible false)
(map-layer-names screen)
Returns a list with strings cooresponding to the name of each layer in the
tiled map in screen
.
Returns a list with strings cooresponding to the name of each layer in the tiled map in `screen`.
(map-layers screen & options)
Returns the MapLayers
in the tiled map in screen
.
(map-layers screen)
Returns the [MapLayers](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/maps/MapLayers.html) in the tiled map in `screen`. (map-layers screen)
(map-layers! object k & options)
Calls a single method on a map-layers
.
(map-layers! object :remove (map-layer screen "objects"))
Calls a single method on a `map-layers`. (map-layers! object :remove (map-layer screen "objects"))
(map-object type & options)
Returns a subclass of MapObject.
(map-object :circle)
Returns a subclass of [MapObject](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/maps/MapObject.html). (map-object :circle)
(map-object! object k & options)
Calls a single method on a map-object
.
(map-object! (map-object :rectangle) :get-rectangle)
Calls a single method on a `map-object`. (map-object! (map-object :rectangle) :get-rectangle)
(map-objects layer & options)
Returns the MapObjects
in the layer
.
(map-objects layer)
Returns the [MapObjects](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/maps/MapObjects.html) in the `layer`. (map-objects layer)
(map-objects! object k & options)
Calls a single method on a map-objects
.
(map-objects! (map-objects layer) :remove (map-object layer 0))
Calls a single method on a `map-objects`. (map-objects! (map-objects layer) :remove (map-object layer 0))
(music path & options)
Returns a Music. Supports wav, mp3, and ogg.
(music "song.wav") (music "song.wav" :play)
Returns a [Music](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/audio/Music.html). Supports wav, mp3, and ogg. (music "song.wav") (music "song.wav" :play)
(music! object k & options)
Calls a single method on a music
.
(music! object :play) (music! object :dispose)
Calls a single method on a `music`. (music! object :play) (music! object :dispose)
(near screen)
Returns the near clipping plane distance of the camera in screen
.
Returns the near clipping plane distance of the camera in `screen`.
(near! screen n)
Sets the near clipping plane distance of the camera in screen
.
Sets the near clipping plane distance of the camera in `screen`.
(net! k & options)
Calls a single method on Gdx.net.
(net! :open-u-r-i "https://sekao.net/")
Calls a single method on [Gdx.net](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/Net.html). (net! :open-u-r-i "https://sekao.net/")
(on-gl & body)
Runs the macro body on the GL thread.
(on-gl (set-screen! my-game main-screen))
Runs the macro body on the GL thread. (on-gl (set-screen! my-game main-screen))
(orthogonal-tiled-map path unit & options)
Returns an OrthogonalTiledMapRenderer
with the tiled map file at path
and unit
scale.
(orthogonal-tiled-map "level1.tmx" (/ 1 8))
Returns an [OrthogonalTiledMapRenderer](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/maps/tiled/renderers/OrthogonalTiledMapRenderer.html) with the tiled map file at `path` and `unit` scale. (orthogonal-tiled-map "level1.tmx" (/ 1 8))
(orthogonal-tiled-map! screen k & options)
Calls a single method on an orthogonal-tiled-map
.
Calls a single method on an `orthogonal-tiled-map`.
(orthographic & options)
Returns an OrthographicCamera.
(orthographic)
Returns an [OrthographicCamera](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/OrthographicCamera.html). (orthographic)
(orthographic! screen k & options)
Calls a single method on an orthographic
.
Calls a single method on an `orthographic`.
(perspective field-of-view viewport-width viewport-height & options)
Returns a PerspectiveCamera.
(perspective 75 (game :width) (game :height))
Returns a [PerspectiveCamera](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/PerspectiveCamera.html). (perspective 75 (game :width) (game :height))
(perspective! screen k & options)
Calls a single method on a perspective
.
Calls a single method on a `perspective`.
(pixmap path & options)
Returns a Pixmap.
(pixmap "image.png")
Returns a [Pixmap](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/Pixmap.html). (pixmap "image.png")
(pixmap! object k & options)
Calls a single method on a pixmap
.
(pixmap! object :dispose)
Calls a single method on a `pixmap`. (pixmap! object :dispose)
(pixmap-format k)
Returns a static field from Pixmap.Format.
(pixmap-format :alpha)
Returns a static field from [Pixmap.Format](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/Pixmap.Format.html). (pixmap-format :alpha)
(position screen)
Returns the position of the camera in screen
.
Returns the position of the camera in `screen`.
(position! screen vec-3)
(position! screen x-val y-val)
(position! screen x-val y-val z-val)
Sets the position of the camera in screen
.
Sets the position of the camera in `screen`.
(pref! name k & options)
Retrieves and stores preferences. The name
should be a unique string.
; define the name we'll be using (def ^:const pref-name "my-game.settings") ; store a single preference (pref! pref-name :put-float "player-health" 40) ; store multiple preferences (pref! pref-name :put {"player-health" 40 "player-x" 20 "player-y" 50}) ; save the changes to the disk (pref! pref-name :flush) ; retrieve a single preference (pref! pref-name :get-float "player-health")
Retrieves and stores preferences. The `name` should be a unique string. ; define the name we'll be using (def ^:const pref-name "my-game.settings") ; store a single preference (pref! pref-name :put-float "player-health" 40) ; store multiple preferences (pref! pref-name :put {"player-health" 40 "player-x" 20 "player-y" 50}) ; save the changes to the disk (pref! pref-name :flush) ; retrieve a single preference (pref! pref-name :get-float "player-health")
(remove-timer! {:keys [update-fn!] :as screen} id)
Stops and removes the timer associated with id
, returning it or nil if not
found.
Stops and removes the timer associated with `id`, returning it or nil if not found.
(render! {:keys [renderer] :as screen})
(render! screen entities)
Calls the renderer from screen
and optionally draws and returns the
entities
.
(render! screen entities)
Calls the renderer from `screen` and optionally draws and returns the `entities`. (render! screen entities)
(render-map! {:keys [renderer camera] :as screen} & [k & layer-names])
Calls the tiled-map renderer from screen
, optionally allowing you to
specify which layers to render with or without.
(render-map! screen :with "water" "grass")
(render-map! screen :without "desert" "rocks")
Calls the tiled-map renderer from `screen`, optionally allowing you to specify which layers to render with or without. (render-map! screen :with "water" "grass") (render-map! screen :without "desert" "rocks")
(render-sorted! screen layer-names entities)
(render-sorted! {:keys [renderer camera update-fn!] :as screen}
sort-fn
layer-names
entities)
Draws the specified layer tiles and entities sorted by their position on the y axis. A custom sort function may be provided. This is primarily intended for games with isometric tiled maps, where the layer tiles often need to be sorted to overlap correctly with the entities.
(render-sorted! screen ["walls"] entities)
(render-sorted! screen #(sort-by :y %) ["walls"] entities)
Draws the specified layer tiles and entities sorted by their position on the y axis. A custom sort function may be provided. This is primarily intended for games with isometric tiled maps, where the layer tiles often need to be sorted to overlap correctly with the entities. (render-sorted! screen ["walls"] entities) (render-sorted! screen #(sort-by :y %) ["walls"] entities)
(render-stage! {:keys [renderer] :as screen})
Calls the stage renderer from screen
.
Calls the stage renderer from `screen`.
(rewind! {:keys [timeline update-fn!] :as screen} steps)
Returns the most recent entities vector saved in the timeline after removing
the last steps
from it. Start recording to the timeline by calling
(update! screen :timeline [])
.
If there are 100 items saved in the timeline and (rewind! screen 1)
is called,
it will remove the last one and return the entities vector from the 99th item.
If steps
is invalid, nil is returned.
If you want to do something more complex with the timeline than a simple rewind,
you can directly access it via (:timeline screen)
. Each item inside it is a
vector containing a timestamp (seconds since the screen was first shown) and an
entities vector.
Returns the most recent entities vector saved in the timeline after removing the last `steps` from it. Start recording to the timeline by calling `(update! screen :timeline [])`. If there are 100 items saved in the timeline and `(rewind! screen 1)` is called, it will remove the last one and return the entities vector from the 99th item. If `steps` is invalid, nil is returned. If you want to do something more complex with the timeline than a simple rewind, you can directly access it via `(:timeline screen)`. Each item inside it is a vector containing a timestamp (seconds since the screen was first shown) and an entities vector.
(scaling k)
Returns a static field from Scaling.
(scaling :fill)
Returns a static field from [Scaling](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/utils/Scaling.html). (scaling :fill)
(screen! screen-object fn-name & options)
Runs a function defined in another screen. You may optionally pass a series of key-value pairs, which will be given to the function via its screen map.
(screen! my-other-screen :on-show)
(screen! my-other-screen :on-change-color :color :blue)
Runs a function defined in another screen. You may optionally pass a series of key-value pairs, which will be given to the function via its screen map. (screen! my-other-screen :on-show) (screen! my-other-screen :on-change-color :color :blue)
(screen->input screen {:keys [x y z] :or {x 0 y 0 z 0} :as entity})
(screen->input screen x y)
(screen->input screen x y z)
Returns a map with the provided x,y,z values converted from screen to input coordinates.
(screen->input screen {:x 10 :y 10 :z 0})
(screen->input screen 10 10)
(screen->input screen 10 10 0)
Returns a map with the provided x,y,z values converted from screen to input coordinates. (screen->input screen {:x 10 :y 10 :z 0}) (screen->input screen 10 10) (screen->input screen 10 10 0)
(screen->isometric screen {:keys [x y] :or {x 0 y 0} :as entity})
(screen->isometric screen x y)
Returns a map with the provided x,y values converted from screen to isometric map coordinates.
(screen->isometric screen {:x 64 :y 32})
(screen->isometric screen 64 32)
Returns a map with the provided x,y values converted from screen to isometric map coordinates. (screen->isometric screen {:x 64 :y 32}) (screen->isometric screen 64 32)
(screenshot!)
(screenshot! path)
Captures a screenshot and either returns it as a pixmap
or saves it to the
specified path.
(screenshot!)
(screenshot! "out.png")
(screenshot! (files! :external "out.png"))
Captures a screenshot and either returns it as a `pixmap` or saves it to the specified path. (screenshot!) (screenshot! "out.png") (screenshot! (files! :external "out.png"))
(set-asset-manager! am)
Sets a global asset manager, which will keep track of objects that need to
be manually disposed, such as texture
entities and pixmap
objects. The
asset manager will then allow you to dispose them all at once.
; create an asset manager
(defonce manager (asset-manager))
; set it to be used by play-clj
(set-asset-manager! manager)
; dispose all assets at once
(asset-manager! manager :clear)
Sets a global asset manager, which will keep track of objects that need to be manually disposed, such as `texture` entities and `pixmap` objects. The asset manager will then allow you to dispose them all at once. ; create an asset manager (defonce manager (asset-manager)) ; set it to be used by play-clj (set-asset-manager! manager) ; dispose all assets at once (asset-manager! manager :clear)
(set-screen! game-object & screen-objects)
Creates and displays a screen for the game-object
, using one or more
screen-objects
in the order they were provided.
(set-screen! my-game main-screen text-screen)
Creates and displays a screen for the `game-object`, using one or more `screen-objects` in the order they were provided. (set-screen! my-game main-screen text-screen)
(set-screen-wrapper! wrapper-fn)
Sets a function that wraps around all screen functions, allowing you to handle errors and perform other custom actions each time they run.
; default behavior
(set-screen-wrapper! (fn [screen-atom screen-fn]
(screen-fn)))
; if there is an error, print it out and switch to a blank screen
; (this is useful because it makes error recovery easier in a REPL)
(set-screen-wrapper! (fn [screen-atom screen-fn]
(try (screen-fn)
(catch Exception e
(.printStackTrace e)
(set-screen! my-game blank-screen)))))
Sets a function that wraps around all screen functions, allowing you to handle errors and perform other custom actions each time they run. ; default behavior (set-screen-wrapper! (fn [screen-atom screen-fn] (screen-fn))) ; if there is an error, print it out and switch to a blank screen ; (this is useful because it makes error recovery easier in a REPL) (set-screen-wrapper! (fn [screen-atom screen-fn] (try (screen-fn) (catch Exception e (.printStackTrace e) (set-screen! my-game blank-screen)))))
(shape type & options)
Returns an entity based on ShapeRenderer.
You may pass in a type (see shape-type
) or an existing shape
entity that you
want to modify.
A shape
can draw multiple sub-shapes internally, allowing you to create more
complicated shapes. If you use assoc
to set the overall :x and :y of the
shape
, each sub-shape's x and y position will be relative to it.
; create a green and red rectangle
(shape :filled
:set-color (color :green)
:rect 0 0 10 30
:set-color (color :red)
:rect 10 0 10 30)
; create an empty shape, then set it to a green rectangle
(shape (shape :filled)
:set-color (color :green)
:rect 0 0 10 30)
; create a green rectangle at 10,10 and rotate it 45 degrees
(assoc (shape :filled
:set-color (color :green)
:rect 0 0 10 30)
:x 10
:y 10
:angle 45)
Returns an entity based on [ShapeRenderer](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/glutils/ShapeRenderer.html). You may pass in a type (see `shape-type`) or an existing `shape` entity that you want to modify. A `shape` can draw multiple sub-shapes internally, allowing you to create more complicated shapes. If you use `assoc` to set the overall :x and :y of the `shape`, each sub-shape's x and y position will be relative to it. ; create a green and red rectangle (shape :filled :set-color (color :green) :rect 0 0 10 30 :set-color (color :red) :rect 10 0 10 30) ; create an empty shape, then set it to a green rectangle (shape (shape :filled) :set-color (color :green) :rect 0 0 10 30) ; create a green rectangle at 10,10 and rotate it 45 degrees (assoc (shape :filled :set-color (color :green) :rect 0 0 10 30) :x 10 :y 10 :angle 45)
(shape! entity k & options)
Calls a single method on a shape
.
Calls a single method on a `shape`.
(shape-type k)
Returns a static field from ShapeRenderer.ShapeType.
(shape-type :filled)
Returns a static field from [ShapeRenderer.ShapeType](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/glutils/ShapeRenderer.ShapeType.html). (shape-type :filled)
(shape? entity)
Returns true if entity
is a shape
.
Returns true if `entity` is a `shape`.
(size! screen width height)
Sets the size of the camera in screen
.
(size! screen 480 360)
Sets the size of the camera in `screen`. (size! screen 480 360)
(sound path & options)
Returns a Sound. Supports wav, mp3, and ogg.
(sound "playerhurt.wav") (sound "playerhurt.wav" :play)
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)
(sound! object k & options)
Calls a single method on a sound
.
(sound! object :play) (sound! object :dispose)
Calls a single method on a `sound`. (sound! object :play) (sound! object :dispose)
(stage & options)
Returns a Stage.
(stage)
Returns a [Stage](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/Stage.html). (stage)
(stage! screen k & options)
Calls a single method on a stage
.
Calls a single method on a `stage`.
(tiled-map s & options)
Returns a TiledMap. Normally, you don't need to use this directly.
Returns a [TiledMap](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/maps/tiled/TiledMap.html). Normally, you don't need to use this directly.
(tiled-map! screen k & options)
Calls a single method on a tiled-map
.
(tiled-map! screen :get-layers)
Calls a single method on a `tiled-map`. (tiled-map! screen :get-layers)
(tiled-map-cell layer x y & options)
Returns a TiledMapTileLayer.Cell
from the layer
at position x
and y
.
(tiled-map-cell (tiled-map-layer screen "water") 0 0)
Returns a [TiledMapTileLayer.Cell](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/maps/tiled/TiledMapTileLayer.Cell.html) from the `layer` at position `x` and `y`. (tiled-map-cell (tiled-map-layer screen "water") 0 0)
(tiled-map-cell! object k & options)
Calls a single method on a tiled-map-cell
.
(-> (tiled-map-layer screen "water") (tiled-map-cell 0 0) (tiled-map-cell! :set-rotation 90))
Calls a single method on a `tiled-map-cell`. (-> (tiled-map-layer screen "water") (tiled-map-cell 0 0) (tiled-map-cell! :set-rotation 90))
(tiled-map-layer screen layer & options)
Returns a TiledMapTileLayer
from the tiled map in screen
that matches layer
.
(tiled-map-layer screen "water")
Returns a [TiledMapTileLayer](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/maps/tiled/TiledMapTileLayer.html) from the tiled map in `screen` that matches `layer`. (tiled-map-layer screen "water")
(tiled-map-layer! object k & options)
Calls a single method on a tiled-map-layer
.
(tiled-map-layer! (tiled-map-layer screen "water") :set-cell 0 0 nil)
Calls a single method on a `tiled-map-layer`. (tiled-map-layer! (tiled-map-layer screen "water") :set-cell 0 0 nil)
(tiled-map-layer* screen layer)
(tiled-map-layer* width height tile-width tile-height)
(up! screen x-val y-val z-val)
Sets the up vector of the camera in screen
.
Sets the up vector of the camera in `screen`.
(update! screen & args)
Runs the equivalent of (swap! screen-atom assoc ...)
, where screen-atom
is the atom storing the screen map behind the scenes. Returns the updated
screen
map.
(update! screen :renderer (stage))
Runs the equivalent of `(swap! screen-atom assoc ...)`, where `screen-atom` is the atom storing the screen map behind the scenes. Returns the updated `screen` map. (update! screen :renderer (stage))
(usage k)
Returns a static field in VertexAttributes.Usage.
Returns a static field in [VertexAttributes.Usage](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/VertexAttributes.Usage.html).
(width screen)
Returns the width of the camera in screen
. If there is no camera, it
returns the overall width.
(width screen)
Returns the width of the camera in `screen`. If there is no camera, it returns the overall width. (width screen)
(width! screen new-width)
Sets the width of the camera in screen
, adjusting the height so the ratio
remains in tact.
(width! screen 480)
Sets the width of the camera in `screen`, adjusting the height so the ratio remains in tact. (width! screen 480)
(x object)
Returns the x position of object
. If object
is a screen, the x position
of the camera will be returned.
Returns the x position of `object`. If `object` is a screen, the x position of the camera will be returned.
(x! object x-val)
Sets only the x position of object
. If object
is a screen, the x position
of the camera will be set.
Sets only the x position of `object`. If `object` is a screen, the x position of the camera will be set.
(y object)
Returns the y position of object
. If object
is a screen, the y position
of the camera will be returned.
Returns the y position of `object`. If `object` is a screen, the y position of the camera will be returned.
(y! object y-val)
Sets only the y position of object
. If object
is a screen, the y position
of the camera will be set.
Sets only the y position of `object`. If `object` is a screen, the y position of the camera will be set.
(z object)
Returns the z position of object
. If object
is a screen, the z position
of the camera will be returned.
Returns the z position of `object`. If `object` is a screen, the z position of the camera will be returned.
(z! object z-val)
Sets only the z position of object
. If object
is a screen, the z position
of the camera will be set.
Sets only the z position of `object`. If `object` is a screen, the z position of the camera will be set.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close