sound volume!
This commit is contained in:
@@ -36,6 +36,7 @@
|
||||
(fn [screen entities]
|
||||
(let [cam (orthographic)
|
||||
viewport (FitViewport. 1280 960 cam)]
|
||||
(utils/load-settings!)
|
||||
(update! screen :renderer (stage) :camera cam :viewport viewport)
|
||||
(.apply viewport)
|
||||
(let [font (utils/get-font "ego/font.fnt")
|
||||
@@ -43,7 +44,8 @@
|
||||
start-playing (center start-playing)
|
||||
quit (assoc (label "Quit thy adventure" (style :label font (color 0.6 1.0 1.0 1.0))) :x 0 :y 50)
|
||||
quit (center quit)
|
||||
music (utils/make-music "intro.ogg")]
|
||||
music (utils/make-music "intro.ogg")
|
||||
ui-skin (skin "ui/ui.json")]
|
||||
(label! start-playing :set-alignment Align/center)
|
||||
|
||||
{:overlay (assoc (texture "title-overlay.png" ) :x 0 :y 0 :scale-x 4 :scale-y 4 :origin-x 0 :origin-y 0)
|
||||
@@ -51,6 +53,16 @@
|
||||
:scale-x 80
|
||||
:scale-y 80
|
||||
:opacity 1.0)
|
||||
:music-volume-slider (assoc (slider {:min 0 :max 100 :step 1} ui-skin :set-value (:music-volume @utils/settings))
|
||||
:x ( - (/ (game :width) 2)
|
||||
150)
|
||||
:width 300
|
||||
:y 200)
|
||||
:sound-volume-slider (assoc (slider {:min 0 :max 100 :step 1 } ui-skin :set-value (:sound-volume @utils/settings))
|
||||
:width 300
|
||||
:x ( - (/ (game :width) 2)
|
||||
150)
|
||||
:y 150)
|
||||
:viewport viewport
|
||||
:font font
|
||||
:music music
|
||||
@@ -60,8 +72,7 @@
|
||||
:quit quit
|
||||
:tweens {:fade-in (tween/tween :fade-in screen [:fade :opacity] 1.0 0.0 1.0
|
||||
:finish #(do (utils/play-sound (:music %)) %)
|
||||
:ease tween/ease-in-quadratic)}
|
||||
})))
|
||||
:ease tween/ease-in-quadratic)}})))
|
||||
|
||||
:on-render
|
||||
(fn [screen [entities]]
|
||||
@@ -71,8 +82,8 @@
|
||||
|
||||
(clear!)
|
||||
(let [entities (utils/apply-tweens screen entities (:tweens entities))]
|
||||
(music! (:music entities) :set-volume 0.0 #_(:volume entities))
|
||||
(render! screen [(:overlay entities) (:start-playing entities) (:quit entities) (:fade entities)])
|
||||
(music! (:music entities) :set-volume (utils/current-music-volume (:volume entities)))
|
||||
(render! screen [(:overlay entities) (:start-playing entities) (:quit entities) (:music-volume-slider entities) (:sound-volume-slider entities) (:fade entities) ])
|
||||
entities))
|
||||
|
||||
:show-screen (fn [entities]
|
||||
@@ -83,6 +94,14 @@
|
||||
(style-label (:start-playing entities) (get-in entities [:font]) [x y])
|
||||
(style-label (:quit entities) (get-in entities [:font]) [x y])
|
||||
entities))
|
||||
:on-ui-changed
|
||||
(fn [screen [entities]]
|
||||
(swap! utils/settings
|
||||
assoc
|
||||
:music-volume (slider! (:music-volume-slider entities) :get-value)
|
||||
:sound-volume (slider! (:sound-volume-slider entities) :get-value))
|
||||
(utils/save-settings!)
|
||||
entities)
|
||||
|
||||
:on-touch-up (fn [screen [entities]]
|
||||
(let [[x y] (utils/unproject screen)]
|
||||
@@ -97,7 +116,7 @@
|
||||
entities)
|
||||
:ease tween/ease-in-cubic))
|
||||
(assoc-in [:tweens :fade-out-music]
|
||||
(tween/tween :fade-out-music screen [:volume] 1.0 0.0 1.8)))
|
||||
(tween/tween :fade-out-music screen [:volume] 1.0 0.0 1.0)))
|
||||
(utils/intersects? (:quit entities) [x y])
|
||||
(-> entities
|
||||
(assoc-in [:tweens :fade-out]
|
||||
@@ -111,6 +130,5 @@
|
||||
nil)))
|
||||
|
||||
:on-resize (fn [screen [entities]]
|
||||
(println (game :width) (game :height) (:width screen) (:height screen))
|
||||
(.update (:viewport entities) (game :width) (game :height) true)
|
||||
nil))
|
||||
|
||||
Reference in New Issue
Block a user