summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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)))))
;;;