summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2018-09-12 17:58:21 -0400
committerDavid Thompson <dthompson2@worcester.edu>2018-09-12 17:58:21 -0400
commit2e354c9e235b382c1870dcaad166b846dbc7287e (patch)
tree94e5cfefc18a36913f3334d2cf9491a19c5e0c84
parent901b024b1f0bc543da379990c5d8c56e9efda8b0 (diff)
Add support for transitions in sequence scene.
-rw-r--r--starling/transition.scm25
1 files changed, 21 insertions, 4 deletions
diff --git a/starling/transition.scm b/starling/transition.scm
index 826032e..3a544f9 100644
--- a/starling/transition.scm
+++ b/starling/transition.scm
@@ -32,6 +32,8 @@
#:use-module (starling scene)
#:export (<sequence-scene>
scenes
+ last-scene
+ transition
<transition>
scene-from
@@ -49,16 +51,31 @@
;; transitioning scenes.
(define-class <sequence-scene> (<scene>)
- (scenes #:accessor scenes #:init-keyword #:scenes))
+ (scenes #:accessor scenes #:init-keyword #:scenes)
+ (last-scene #:accessor last-scene #:init-form #f)
+ (transition #:accessor transition #:init-keyword #:transition
+ #:init-form default-sequence-transition))
+
+(define (default-sequence-transition from to)
+ ;; Return the 'to' scene as-is, which means there is no transition
+ ;; at all.
+ to)
(define-method (on-enter (sequence <sequence-scene>))
+ (define (next-scene-transition scene)
+ (let ((last (last-scene sequence)))
+ (if last
+ ((transition sequence) last scene)
+ scene)))
(match (scenes sequence)
((scene)
;; If we've reached the last scene, we're done!
- (replace-scene scene))
+ (replace-scene (next-scene-transition scene)))
((scene . rest)
- (set! (scenes sequence) rest)
- (push-scene scene))))
+ (let ((next-scene (next-scene-transition scene)))
+ (set! (scenes sequence) rest)
+ (set! (last-scene sequence) scene)
+ (push-scene next-scene)))))
;;;