nice transitions.

This commit is contained in:
2014-09-17 12:26:38 -07:00
parent 8f32ec50d3
commit 28728bba27
3 changed files with 29 additions and 5 deletions

View File

@@ -149,14 +149,35 @@
(defn transition-background [entities new-background [x y]]
(run-action entities
(begin [this screen entities]
(-> entities
(assoc-in [:transition]
(assoc (texture "black.png")
:scale-x 20
:scale-y 20
:baseline 9500
:opacity 0.1))))
(continue [this screen entities]
(update-in entities [:transition :opacity] + 0.075))
(done? [this screen entities]
(>= (get-in entities [:transition :opacity]) 1.0))
(terminate [this screen entities]
entities))
(run-action entities
(begin [this screen entities]
(-> entities
(assoc-in [:background] (get-in entities [:backgrounds new-background]))
(assoc-in [:ego :x] x)
(assoc-in [:ego :y] y)))
(continue [this screen entities] entities)
(continue [this screen entities]
(update-in entities [:transition :opacity] - 0.075))
(done? [this screen entities] true)
(done? [this screen entities]
(<= (get-in entities [:transition :opacity]) 0.0))
(terminate [this screen entities]
entities)))
(dissoc entities :transition))))