50 lines
1.6 KiB
Clojure
50 lines
1.6 KiB
Clojure
(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]
|
|
|
|
[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.utils Align]
|
|
[com.badlogic.gdx Application Audio Files Game Gdx Graphics Input
|
|
InputMultiplexer InputProcessor Net Preferences Screen]
|
|
[com.badlogic.gdx.utils.viewport FitViewport]))
|
|
(println "loading " *ns*)
|
|
|
|
|
|
(defscreen fade-screen
|
|
:on-show
|
|
(fn [screen entities options]
|
|
(let [[screen global-atlas] (utils/acquire-atlas screen "packed/global.atlas")]
|
|
(utils/setup-viewport screen 320 240)
|
|
|
|
{:fade (assoc (utils/atlas->texture global-atlas "black.png")
|
|
:scale-x 100
|
|
:scale-y 100
|
|
:x -1
|
|
:y -1
|
|
:opacity 1.0
|
|
:origin-x 0
|
|
:origin-y 0)}))
|
|
|
|
|
|
:on-render
|
|
(fn [screen entities options]
|
|
(render! screen [(:fade entities)])
|
|
entities)
|
|
|
|
:on-hide
|
|
(fn [screen entities options]
|
|
(utils/release-resources screen))
|
|
|
|
:update-fade (fn [_ entities {:keys [opacity]}]
|
|
(assoc-in entities [:fade :opacity] opacity))
|
|
|
|
:on-resize (fn [{:keys [^FitViewport viewport]} entities {:keys [width height]}]
|
|
(.update ^FitViewport viewport width height)))
|
|
|