fading covers all.

This commit is contained in:
2015-05-01 18:09:03 -07:00
parent 8fe72959d2
commit 23d90e1a05
3 changed files with 46 additions and 8 deletions

View File

@@ -0,0 +1,40 @@
(ns advent.screens.fade
(:require [play-clj.core :refer :all]
[play-clj.ui :refer :all]
[play-clj.utils :refer :all]
[play-clj.g2d :refer :all]
[clojure.pprint]
[advent.pathfind]
[advent.zone :as zone]
[advent.utils :as utils])
(:import [com.badlogic.gdx.graphics Pixmap Pixmap$Filter Texture Texture$TextureFilter]
[com.badlogic.gdx.graphics.g2d TextureRegion]
[com.badlogic.gdx.scenes.scene2d.utils Align]
[com.badlogic.gdx Application Audio Files Game Gdx Graphics Input
InputMultiplexer InputProcessor Net Preferences Screen]))
(defscreen fade-screen
:on-show
(fn [screen entities]
(utils/setup-viewport screen 320 240)
{:fade (assoc (texture "black.png")
:scale-x 80
:scale-y 80
:opacity 0.0
:origin-x 0
:origin-y 0)})
:on-render
(fn [screen [entities]]
(render! screen [(:fade entities)])
entities)
:update-fade (fn [{:keys [opacity]} [entities]]
(assoc-in entities [:fade :opacity] opacity))
:on-resize (fn [{:keys [width height viewport]} entities]
(.update viewport width height)))

View File

@@ -15,6 +15,7 @@
[advent.utils :as utils]
[advent.tween :as tween]
[advent.screens.rooms :as rooms]
[advent.screens.fade :refer [fade-screen]]
[advent.screens.items :as items]
[advent.screens.rooms.dream :as rooms.dream]
[advent.screens.rooms.castle-gate :as rooms.castle-gate]
@@ -596,13 +597,8 @@
:sounds {:blink (sound "blink-other.ogg")
:object nil}
:fade (assoc (texture "black.png")
:scale-x 20
:scale-y 20
:baseline 9500
:opacity 0.0
:origin-x 0
:origin-y 0)
:fade {:object nil
:opacity 0.0}
:white-fade (assoc (texture "white.png")
:scale-x 20
:scale-y 20
@@ -697,6 +693,7 @@
all-entities (concat (vals entities) layers (vals (get-in entities [:room :entities])))]
(screen! talking-screen :on-update-camera :scene-viewport (:viewport screen) :scene-camera (:camera screen))
(screen! fade-screen :update-fade :opacity (get-in entities [:fade :opacity]))
(when true #_(not (get-in entities [:cam :paused?]))
(set! (. camera zoom) (:zoom (:cam entities)))
(set! (.. camera position x) (:x (:cam entities) 160.0))

View File

@@ -10,6 +10,7 @@
[advent.screens.title :as title]
[advent.screens.inventory :as inventory]
[advent.screens.safe :as safe]
[advent.screens.fade :as fade]
)
(:import [com.badlogic.gdx.graphics Pixmap Pixmap$Filter Texture Texture$TextureFilter]
[com.badlogic.gdx.graphics.g2d TextureRegion]
@@ -110,7 +111,7 @@
(tween/tween :fade-out screen [:fade :opacity] 0.0 1.0 1.0
:finish (fn [entities]
(utils/stop-sound (:music entities))
(set-screen! @(resolve 'advent.core/advent) scene/scene scene/hud dialogue/talking-screen dialogue/choice-screen inventory/inventory-screen safe/safe-screen)
(set-screen! @(resolve 'advent.core/advent) scene/scene scene/hud dialogue/talking-screen dialogue/choice-screen inventory/inventory-screen safe/safe-screen fade/fade-screen)
entities)
:ease tween/ease-in-cubic))
(assoc-in [:tweens :fade-out-music]